手動(dòng)實(shí)現(xiàn)將本地jar添加到Maven倉(cāng)庫(kù)
手動(dòng)將本地jar添加到Maven倉(cāng)庫(kù)
將jar添加到本地倉(cāng)庫(kù)的做法
以下面pom.xml依賴的jar包為例:
實(shí)際項(xiàng)目中pom.xml依賴寫(xiě)法:
<dependency> ? ? <groupId>org.springframework</groupId> ? ? <artifactId>spring-context-support</artifactId> ? ? <version>3.1.0.RELEASE</version> </dependency>
Maven 安裝 JAR 包的命令是:
mvn install:install-file? -Dfile=jar包的位置? -DgroupId=上面的groupId? -DartifactId=上面的artifactId? -Dversion=上面的version? -Dpackaging=jar
例如我的這個(gè)spring-context-support-3.1.0.RELEASE.jar 文件放在了"D:\mvn\"中
則命令為:
mvn install:install-file? -Dfile=D:\mvn\spring-context-support-3.1.0.RELEASE.jar? -DgroupId=org.springframework? -DartifactId=spring-context-support? -Dversion=3.1.0.RELEASE? -Dpackaging=jar
注意:任何路徑和名稱不要有中文和空格,以防出現(xiàn)莫名其妙的錯(cuò)誤。
還可以解決本地倉(cāng)庫(kù)是從別人那邊復(fù)制的,但是需要的jar包中央倉(cāng)庫(kù)不存在,導(dǎo)致的執(zhí)行package時(shí)出現(xiàn)以下異常
Failed to execute goal on project relayserver: Could not resolve dependencies for project com.xxx:xxx:war:1.0-SNAPSHOT: Failure to find xxx.xxx:xxx:jar:1.0 in http://maven.aliyun
.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed or updates are forced
不講jar包添加到本地倉(cāng)庫(kù)也可在maven工程中使用外部jar包做法
假設(shè)將包htmlparser.jar放入了項(xiàng)目下的lib目錄中 :
-> ${project}/lib/htmlparser.jar則pom.xml文件中依賴可以如下:
<dependency>
? ? <groupId>com.htmlparser</groupId>
? ? <artifactId>htmlparser</artifactId>
? ? <version>2.0</version>
? ? <scope>system</scope>
? ? <systemPath>${project.basedir}/lib/htmlparser.jar</systemPath>
</dependency>手動(dòng)向maven倉(cāng)庫(kù)添加jar包的cmd命令
手動(dòng)向maven庫(kù)里面添加jar包,要以管理員身份進(jìn)行添加,在jar包目錄打開(kāi)cmd
mvn install:install-file -Dfile=文件絕對(duì)路徑 -DgroupId=maven倉(cāng)庫(kù)下面的路徑 -DartifactId=jar包名-Dversion=jar包版本 -Dpackaging=jar -DgeneratePom=true
例如:
mvn install:install-file -Dfile=E:/quartz-2.2.1.jar -DgroupId=org.quartz-scheduler -DartifactId=quertz -Dversion=2.2.1 -Dpackaging=jar -DgeneratePom=true
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Spring?Boot超大文件上傳實(shí)現(xiàn)秒傳功能
這篇文章主要介紹了Spring?Boot超大文件上傳實(shí)現(xiàn)秒傳功能,在實(shí)現(xiàn)分片上傳的過(guò)程,需要前端和后端配合,比如前后端的上傳塊號(hào)的文件大小,前后端必須得要一致,否則上傳就會(huì)有問(wèn)題,需要的朋友可以參考下2022-12-12
springboot中使用jpa下hibernate的ddl-auto方式
這篇文章主要介紹了springboot中使用jpa下hibernate的ddl-auto方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-02-02
如何解決Could not transfer artifact org.spri
在Maven更新過(guò)程中遇到“Could not transfer artifact org.springframework.boot”錯(cuò)誤通常是由于網(wǎng)絡(luò)問(wèn)題,解決方法是在Maven的設(shè)置中忽略HTTPS,添加特定語(yǔ)句后,可以正常下載依賴,但下載速度可能較慢,這是一種常見(jiàn)的解決方案,希望對(duì)遇到相同問(wèn)題的人有所幫助2024-09-09
出現(xiàn)次數(shù)超過(guò)一半(50%)的數(shù)
給出n個(gè)數(shù),需要我們找出出現(xiàn)次數(shù)超過(guò)一半的數(shù),下面小編給大家分享下我的實(shí)現(xiàn)思路及關(guān)鍵代碼,感興趣的朋友一起學(xué)習(xí)吧2016-07-07
Java兩大工具庫(kù)Commons和Guava使用示例詳解
這篇文章主要為大家介紹了Java兩大工具庫(kù)Commons和Guava使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-02-02
教你快速搭建sona服務(wù)及idea使用sona的方法
Sonar 是一個(gè)用于代碼質(zhì)量管理的開(kāi)放平臺(tái)。通過(guò)插件機(jī)制,Sonar 可以集成不同的測(cè)試工具,代碼分析工具,以及持續(xù)集成工具,本文給大家分享搭建sona服務(wù)及idea使用sona的方法,感興趣的朋友一起看看吧2021-06-06
mybatis-parameterType傳入map條件方式
這篇文章主要介紹了mybatis-parameterType傳入map條件方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12
JAVA實(shí)現(xiàn)二維碼生成加背景圖代碼實(shí)例
這篇文章主要介紹了JAVA實(shí)現(xiàn)二維碼生成加背景圖代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-12-12

