问题:将本地的jar引入maven工程,scope为system,这种情况下打包生产的jarbao中不带有本地的jar包,从而导致打出来的jar执行报错。
<dependency>
<groupId>com.huawei</groupId>
<artifactId>esdk_token_auth</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/libs/esdk_token_auth_3.3.0.jar</systemPath>
</dependency>
解决:通过mvn install命令将需要引入的本地jar包安装到maven仓库中,再在工程的pom文件中引入相应的依赖即可,这样打包出来的jar包中包含我们需要引入的本地jar
mvn install:install-file -Dfile=esdk_token_auth_3.3.0.jar -DgroupId=com.huawei.esdk.commons -DartifactId=esdk_token_auth -Dversion=3.3.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing D:\GoProject\src\eSDK\src\extends\authadv\sdk\token-auth\target\esdk_token_auth_3.3.0.jar to D:\opt\maven\eSDK\rc101\com\huawei\esdk\commons\esdk_token_auth\3.3.0\esdk_token_auth-3.3.0.jar
[INFO] Installing C:\Users\H00370~1\AppData\Local\Temp\mvninstall2404161770516686221.pom to D:\opt\maven\eSDK\rc101\com\huawei\esdk\commons\esdk_token_auth\3.3.0\esdk_token_auth-3.3.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.906 s
[INFO] Finished at: 2018-09-28T14:16:59+08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
<dependency>
<groupId>com.huawei.esdk.commons</groupId>
<artifactId>esdk_token_auth</artifactId>
<version>3.3.0</version>
</dependency>