Maven中使用本地JAR包
阿新 • • 發佈:2019-01-10
在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