溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

maven無(wú)法下載依賴的jar包怎么辦

發(fā)布時(shí)間:2020-07-10 16:11:01 來(lái)源:億速云 閱讀:1041 作者:Leah 欄目:編程語(yǔ)言

今天就跟大家聊聊有關(guān)maven無(wú)法下載依賴的jar包怎么辦,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。

公司內(nèi)部有搭建maven私服,自己做了個(gè)核心jar包,一開(kāi)始是xxx-core.1.0.0.SNAPSHOT版本,是本地和項(xiàng)目環(huán)境都可以正常使用的。為支持上線,發(fā)布穩(wěn)定版本,xxx-core.1.0.0.jar。

本地編譯正常,啟動(dòng)正常,項(xiàng)目環(huán)境,gitlab提交后自動(dòng)部署到Rancher時(shí),發(fā)現(xiàn)始終下載不下來(lái)jar包。

pom.xml文件的repository配置:

<repositories>
        <repository>
            <id>xxxxx.releases</id>
            <name>Releases</name>
            <url>https://nexus.xxxxxx.com/repository/maven-releases</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>xxxxxx.snapshots</id>
            <name>Snapshot</name>
            <url>https://nexus.huilianyi.com/repository/maven-snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository></repositories>

編譯時(shí)maven報(bào)錯(cuò)提示:

Failed to execute goal on project service: Could not resolve dependencies for project com.xxxxx:service:war:1.0-SNAPSHOT: Failure to find com.xxxxx-core:jar:1.0.0 in https://nexus.xxxx.com/repository/maven-releases was cached in the local repository, resolution will not be reattempted until the update interval of xxx.releases has elapsed or updates are forced -> [Help 1]

提示是說(shuō),是私庫(kù)配置的repository的這個(gè)id:xxx.releases 有緩存更新間隔,沒(méi)到這個(gè)更新時(shí)間,是從緩存里面獲取jar的,所以新上傳到倉(cāng)庫(kù)xxx-core.1.0.0.jar這個(gè)jar包是不在緩存里面的

所以沒(méi)有拉取下來(lái)。

解決辦法:

pom.xml更改為:

<repositories>
        <repository>
            <id>xxxxx.releases</id>
            <name>Releases</name>
            <url>https://nexus.xxxxxx.com/repository/maven-releases</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>xxxxxx.snapshots</id>
            <name>Snapshot</name>
            <url>https://nexus.huilianyi.com/repository/maven-snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository></repositories>

<updatePolicy>標(biāo)簽是更新策略,always是總是下載倉(cāng)庫(kù)中最新的依賴。
更多相關(guān)內(nèi)容:

解決maven無(wú)法下載插件的方法

maven無(wú)法下載依賴jar包的原因以及解決方案

看完上述內(nèi)容,你們對(duì)maven無(wú)法下載依賴的jar包怎么辦有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注億速云行業(yè)資訊頻道,感謝大家的支持。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI