Maven install error: Dependency could not be resolved

后端 未结 6 1837
庸人自扰
庸人自扰 2020-11-27 23:33

I am using Maven 3.1.1. When I run mvn install I get the following error:

D:\\spring source>mvn install
[INFO] Scanning for projects...
[INFO         


        
相关标签:
6条回答
  • 2020-11-27 23:48

    Where is my Settings.xml?

    Windows users

    It's in your C:/Users/<Username>/.m2/settings.xml

    Also, this is for specific user. Global one can be present at :

    <Maven-Installation-Directory>/conf/settings.xml

    But changing the User one might solve the issue if you can't find the global one.

    Also, equally important, go to Preferences in Eclipse/STS:

    • Goto Maven -> User Settings and verify if both global and user settings.xml files are mentioned in the properties, if not mention them by browsing.

    1. Proxy Issue

    Check Windows Proxy Setting. If there is any proxy which your computer is using then you need to add proxy settings in your settings.xml file too.

    Just add this chunk of code in your settings.xml

    <proxies>
       <proxy>
          <id>proxy-id</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>ca-something.net</host>
          <port>80</port>
          <nonProxyHosts>localhost|10.140.240.90.*</nonProxyHosts>
        </proxy>
      </proxies> 
    

    2. Protocol Issue

    Visit http://repo.maven.apache.org/: If it says Https required.

    Then, you need to add this chunk of code to your settings.xml inside <mirrors>

    <mirror>
      <id>central-secure</id>
      <url>https://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    

    Now it should be good to go.

    3. None of the above works

    Try disconnecting any company private VPN and try mvn clean build.

    0 讨论(0)
  • 2020-11-27 23:51

    This issue was resolved for us by providing the correct proxy host in .m2/settings.xml.

    Example:

    <proxies>
       <proxy>
          <id>XXXXXXXXXX</id>
          <active>true</active>
          <protocol>http</protocol>
          <host>na-xxxx-proxy.na.xxxxxxxxxx.net</host>
          <port>80</port>
          <nonProxyHosts>localhost|10.140.240.90.*</nonProxyHosts>
        </proxy>
      </proxies> 
    
    0 讨论(0)
  • 2020-11-27 23:56

    This is caused by corrupted maven or plugins folder. To resolve this:

    1. Delete \.m2\repository\org\apache\maven
    2. mvn dependency:resolve -X
    0 讨论(0)
  • 2020-11-28 00:04

    This error comes due to the proxy settings.

    First of all, check whether you are able to connect to maven repository(http://repo1.maven.org/maven2) from browser.

    Then update Maven proxy setting create/update a settings.xml in .m2 directory with following details:

     <proxies>
        <proxy>
          <active>true</active>
          <protocol>http</protocol>
          <host>{your proxy server host name}</host>
          <port>{your proxy server port}</port>
          <nonProxyHosts>maven</nonProxyHosts>
        </proxy>
      </proxies>
    

    Solution given by Maven community: http://maven.apache.org/guides/mini/guide-proxies.html

    0 讨论(0)
  • 2020-11-28 00:05

    Could not transfer artifact org.apache.maven.plugins:maven-dependency-plugin:pom:2.8 from/to central (http://repo.maven.apache.org/maven2): repo.maven.apache.org: Unknown host repo.maven.apache.org

    It seems like your maven cannot access remote central repository.

    • Check if you have an established internet connection.
    • Check if you can access default maven repo http://repo.maven.apache.org/maven2 in your browser.
    • Check if you have correct configuration in <repositories> and <proxies> in your your settings.xml
    0 讨论(0)
  • 2020-11-28 00:10

    Probably a bit late to the party, but there appears to be an unknown host exception thrown out of maven even if the resource/dependency is unavailable at that address.

    Which could mean that the problem may actually be that you have a transitive dependency that is pointing you to the wrong version of a jar (or one that is transitively included multiple times - one of which may be an unresolvable version). (I see it's looking for version 2.8 of the plugin but you specified version 3.1.1, so it's likely you have another dependency transitively including the wrong version).

    You can exclude transitive inclusion of a dependency using the exclusions tag.

    0 讨论(0)
提交回复
热议问题