由于是maven项目,所有jar都来自于maven仓库, 但是有例外的, 项目中包含了阿里爸爸的jar, 如果不配置的话直接打包是会报:java.lang.ClassNotFoundException, 配置如下:
1,在项目中新建lib文件夹,将本地的jar拷贝进去
2,将jar包含到项目中
<dependency>
<groupId>taobao</groupId>
<artifactId>taobao-sdk-java</artifactId>
<version>20160607</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/taobao-sdk-java-auto_1455552377940-20160607.jar
</systemPath>
</dependency>
<dependency>
<groupId>alipay</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>20171201160035</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/alipay-sdk-java20171201160035.jar
</systemPath>
</dependency>
3,配置打包资源(关键)
在<build>节点中,如果没有build节点,放在和<dependencies>平级
<resources>
<resource>
<directory>lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<targetPath>BOOT-INF/classes/</targetPath>
</resource>
</resources>
网友评论