Springboot导入本地jar后 打包依赖无法加入的解决方案
程序员文章站
2022-04-19 15:50:18
目录springboot导入本地jar后 打包依赖无法加入1.本地jar包2.pom文件添加自定义jar包导入3.添加项目引入本地jar包,并设置maven打包一并打入pom文件中引入本地jar包依赖...
springboot导入本地jar后 打包依赖无法加入
1.本地jar包
2.pom文件添加自定义jar包导入
<!--自定义jar--> <dependency> <groupid>epublib-core</groupid> <artifactid>1.0</artifactid> <scope>system</scope> <systempath>${project.basedir}/lib/epublib-core-latest.jar</systempath> <version>1.0.0</version> </dependency>
3.添加
<build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> </plugin> <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> </plugin> </plugins> <resources> <resource> <filtering>true</filtering> <directory>${basedir}/src/main/resources</directory> <includes> <include>**/bootstrap*.yml</include> <!--这三个我本地配置文件,具体配置根据需求修改--> <include>**/bootstrap*.yaml</include> <include>**/bootstrap*.properties</include> </includes> </resource> <resource> <directory>${basedir}/src/main/resources</directory> <excludes> <exclude>**/bootstrap*.yml</exclude> <!--这三个我本地配置文件,具体配置根据需求修改--> <exclude>**/bootstrap*.yaml</exclude> <exclude>**/bootstrap*.properties</exclude> </excludes> </resource> <resource> <directory>${basedir}/lib</directory> <targetpath>boot-inf/lib/</targetpath> <includes> <include>**/*.jar</include> </includes> </resource> </resources> </build>
项目引入本地jar包,并设置maven打包一并打入
resources目录下新建lib文件夹,然后将需要的本地jar包放入进去
pom文件中引入本地jar包依赖
<dependency> <groupid>com.xxx</groupid> <artifactid>xxxxx</artifactid> <version>0.0.1-snapshot</version> <scope>system</scope> <systempath>${project.basedir}/src/main/resources/lib/xxxxx.jar</systempath> </dependency>
在springboot的maven工具增加includesystemscope功能
作用:打包时将scope为system的jar包一并打入包内
<plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> <!-- 作用:项目打成jar的同时将本地jar包也引入进去 --> <configuration> <includesystemscope>true</includesystemscope> </configuration> </plugin>
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。