springboot项目引入第三方jar后打包运行时找不到类
今天遇上这个问题,真是费劲,idea调试没问题,打jar包后再linux’服务器上运行就报错ClassNotfund我的解决办法如下:
1.首先检查你的jar包是否已经引入
idea是在file-》project structure-》Libraries中
2.在pom中添加你的jar包路径
你需要修改一下路径指向你的jar包。 ${project.basedir}指向根目录,即src所在目录。 <scope>system</scope>一定要有!
<dependency>
<groupId>xxxxx</groupId>
<artifactId>xxxxx</artifactId>
<version>2.3.1-RELEASE</version>
<scope>system</scope>
<systemPath>${
project.basedir}/libs/xxxxx.jar</systemPath>
</dependency>
3.在pom中添加编译插件
版本和你的springboot版本保持一致 <includeSystemScope>true</includeSystemScope>一定要有!!
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.1.6.RELEASE</version> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
打包运行一下,问题应该已经解决了,很开心能够帮助到你~
