在Maven项目中使用本地JAR包有两种方法:
1. 使用system scope
<dependencies> <dependency> <groupId>org.richard</groupId> <artifactId>my-jar</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/lib/my-jar.jar</systemPath> </dependency> </dependencies>
缺点:system scope引入的包,在使用jar-with-dependencies打包时将不会被包含,可以使用resources将本地包打进jar-with-dependencies
2. 将jar包安装到本地repository中
mvn install:install-file -Dfile=ngdbc.jar -DgroupId=org.sap.jdbc -DartifactId=ngdbc -Dversion=1.0 -Dpackaging=jar
使用jar-with-dependencies打包时将会被包含
你的jar包及路径必须严格遵循格式:
/groupId/artifactId/version/artifactId-verion.jar