Maven報錯Failed to collect dependencies at com.***:***:jar:1.0.0


問題

mvn install后報錯,使用mvn -X install使用debug模式查看,顯示如下信息,意思是這個jar包的依賴包下載不到。

 

解決辦法

添加倉庫即可,可以去setting中添加mirror或profile下的repository,同時需要用activeProfiles激活profile。

去maven的setting中修改mirrors

        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
            <id>uk</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://uk.maven.org/maven2/</url>
        </mirror>
        <mirror>
            <id>CN</id>
            <name>OSChina Central</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <mirror>
            <id>nexus</id>
            <name>internal nexus repository</name>
            <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
            <url>http://repo.maven.apache.org/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

用profile,同時需要密碼的記得配置server,id要一致

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- 讀取mvn庫用,選擇要激活的profile -->
  <activeProfiles>
    <activeProfile>github</activeProfile>
  </activeProfiles>
  <!-- 讀取mvn庫用,配置一系列profile,一定要寫到具體倉庫 -->
  <profiles>
    <profile>
      <id>github</id>
      <repositories>
        <repository>
          <id>github</id>
          <name>GitHub AutKevin Apache Maven Packages</name>
          <url>https://maven.pkg.github.com/AutKevin/maven-repo</url>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <!-- 上面兩項也可以不配置,只不過每次都要在pom.xml文件中配置,這里配置可以一勞永逸 -->
</settings>

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM