1. 程式人生 > >Maven 新增中央倉庫中沒有的jar

Maven 新增中央倉庫中沒有的jar

jar檔案需要放到當前目錄下,執行以下命令,設定groupId,artifactId,version資訊,方便專案pom引用

mvn install:install-file -Dfile=xxx.jar -Dpackaging=jar -DgroupId=xxx -DartifactId=xxx -Dversion=x

執行完畢,即可把jar裝載到本地倉庫,專案中可直接使用引入依賴

譬如要載入sqljdbc.jar

mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.
sqlserver -DartifactId=sqljdbc4 -Dversion=4.0

pom.xml在 dependencies 節點加入(需要與之前install的groupId等資訊一致)

<dependency>

    <groupId>com.microsoft.sqlserver</groupId>

    <artifactId>sqljdbc4</artifactId>

    <version>4.0</version>

</dependency>