项目中引入的本地的jar包,在自己本地运行也是没有任何问题,但是在打包发布的时候就会报错找不到自己引入的文件。
刚开始在网上找决绝办法是感觉很简单。
下面是网上最多的解决办法:
1.首先在pom中添加本地jar包的依赖
其中groupId artifactId 和version自己随便写。scope作用于定义为system,systemPath定义为jar包在项目中的路径(${basedir}就是项目的根目录):
<dependency>
<groupId>com.xxx.util</groupId>
<artifactId>com.xxx.util</artifactId>
<version>1.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/xxx.jar</systemPath>
</dependency>
2.光做这些还是不够的,这样只能保证我们在本地能够正常运行,打包还是不会被打包进去,所以说我们需要在引入的springboot的maven插件中告诉maven,将我们的刚刚引入的作用域为system的本地jar也打包进来
看起来是不是很简单,但是我打包时还报错。
然后我又开始寻找办法之旅。。。。。
终于找到解决办法特此记录。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/resources/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
这样配置打包成功!!!!!
版权声明:本文为bianqi3原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。