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>
 

猜你喜欢

转载自www.cnblogs.com/aeolian/p/12468493.html
今日推荐