在用spring boot 做项目开发的时候,都是直接从mavn仓库中拉取jar值不会遇到现有问题的。最近在做项目的时候由于用到了第三的jar包时候,用spring boot打包遇到的问题。
开发工具idea
1: 将项目打包成 可执行的jar文件
按照以前整合项目的套路,直接将第三种的jar添加项目lib中即可。我也是这么做的,在项目中新建lib文件夹,将第三放的jar copy进去。
2:依然dependency标签引入第三种jar,写法如下
scopre 写成system , systemPath : 指向jar所在的位置。 不要按照以前的套路,在libraries中添加进来了。
3: 按照上述步骤,ide开发部署是没有问题的。但是打包mvn clean package,第三方的jar,还是未能打进去,运行项目就会提示缺少jar文件。
4:在spring-boot-maven-plugin中configuration下的includeSystemScope属性指定为true即可了。
goal-repackage属性为true,因为项目是多模块的,不然打包后文件不能将依赖文件打包进去。
经过以上折腾,不管是ide开发部署,还是打包都没问题了。
我抄的https://blog.csdn.net/chenxidong9/article/details/79412585这位的
-----------------------------------------------------------------------------------------------------------------
1 步
2 pom添加
3 ide开发部署是没有问题的。但是打包mvn clean package,第三方的jar,还是未能打进去,运行项目就会提示缺少jar文件。
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
<!-- <configuration>
<mainClass>spring boot的main.java路径</mainClass>
</configuration>-->
</plugin>