<dependency>
<groupId>xxxxx</groupId>
<artifactId>xxxxx</artifactId>
<version>XXXXXX</version>
<scope>system</scope>
<systemPath>${}/libs/</systemPath>
</dependency>
在项目中如上所示,将第三方jar包放到项目资源目录下,引入jar包使用。
本地运行一切OK,但是打包后部署到服务器后,执行相关第三方jar包的方法,会报错:
nested exception is ,找不到对应的类。
解决方法:
在项目的pom文件中引入下列配置项,其中
<includeSystemScope>true</includeSystemScope>标签是关键。引入了以后重新打包就能解决问题了。
注意:<version>一定要跟springboot的版本一致。
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${}</finalName>
<plugins>
<!-- 打包 -->
<plugin>
<groupId></groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
</goals>
</execution>
</executions>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>