一、dependency 本地jar包
<dependency>
<groupId>com.dataozi</groupId> <!--自定义-->
<artifactId>sdk</artifactId> <!--自定义-->
<version>1.0.0</version> <!--自定义-->
<scope>system</scope> <!--system,类似provided,需要显式提供依赖的jar以后,Maven就不会在Repository中查找它-->
<systemPath>${libpath}/lib/sdk-1.0.0.jar</systemPath> <!--项目根目录下的lib文件夹下-->
</dependency>
二、编译阶段指定外部lib
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>lib</extdirs><!--指定外部lib-->
</compilerArguments>
</configuration>
</plugin>
三、将外部jar打入本地maven仓库(推荐)
使用maven命令在指定maven仓库路径打好jar包
mvn install:install-file -Dfile=${jar包路径} -DgroupId=${groupId} -DartifactId=${
artifactId
} -Dversion=${指定版本} -Dpackaging=${指定打包方式}
mvn install:install-file -Dfile=test.jar -DgroupId=com.dataozi -DartifactId=sdk
-Dversion=1.0.0 -Dpackaging=jar
在项目中直接引入jar包
<dependency>
<groupId>com.dataozi</groupId>
<artifactId>sdk</artifactId>
<version>1.0.0</version>
</dependency>