Window下, maven包缺失處理 ::將本地jar包或者遠端倉庫jar包, 新增到本地Maven倉庫
阿新 • • 發佈:2019-01-05
#準備
安裝meaven,並配置到環境變數
#遠端庫Jar包新增到本地倉庫
1.把如下文字儲存為pom.xml
<?xml version="1.0"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>temp.download</groupId> <artifactId>temp-download</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <!-- 需要下載什麼jar包 新增相應依賴 其餘部分無需在意--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.11</version> </dependency> <!-- 需要下載什麼jar包 新增相應依賴 其餘部分無需在意--> </dependencies> </project>
3.儲存如下文字為pom.bat
call mvn -f pom.xml dependency:copy-dependencies
@pause
4.pom.xml和pom.bat放在同一目錄下
5.使用缺失包地址, 替換pom.xml的17到21行 (地址可在http://mvnrepository.com/搜尋獲得)
示例地址 <!-- https://mvnrepository.com/artifact/batik/batik-util --> <dependency> <groupId>batik</groupId> <artifactId>batik-util</artifactId> <version>1.6-1</version> </dependency>
6.執行pom.bat
7.後續若是其他包缺失重複步驟5和6
#本地包新增到maven本地倉庫
1.複製如下文字儲存為local.bat
mvn install:install-file -Dfile=jave-1.0.2.jar -DgroupId=fakepath -DartifactId=jave -Dversion=1.0.2 -Dpackaging=jar ::-Dfile=xxx //jar包名 ::-DgroupId=xxx //groupId ::-DartifactId=xxx //artifactId ::-Dversion=xxx //version ::-Dpackaging=jar/war //jar包還是war包
2.將本地Jar包放置到local.bat所在目錄
3.根據你的jar包,修改local.bat中對應引數