springboot项目引入第三方jar后打包运行时找不到类

179 字
1 分钟
springboot项目引入第三方jar后打包运行时找不到类

今天遇上这个问题,真是费劲,idea调试没问题,打jar包后再linux’服务器上运行就报错ClassNotfund我的解决办法如下:

1.首先检查你的jar包是否已经引入#

idea是在file-》project structure-》Libraries中

2.在pom中添加你的jar包路径#

你需要修改一下路径指向你的jar包。 ${project.basedir}指向根目录,即src所在目录。 system一定要有!

<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版本保持一致 true一定要有!!

<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>

打包运行一下,问题应该已经解决了,很开心能够帮助到你~

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

springboot项目引入第三方jar后打包运行时找不到类
https://czxcly.cn/posts/springboot项目引入第三方jar后打包运行时找不到类/
作者
启源学社
发布于
2022-08-10
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
启源学社
公告
欢迎来到我的博客!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
45
分类
2
标签
16
总字数
16,178
运行时长
0
最后活动
0 天前

文章目录