maven can't find dependencies [dependencyResolutionException]

眉间皱痕 提交于 2019-12-10 17:39:46

问题


In my pom.xml I have

    <repositories>
        <repository>
            <id>rep</id>
            <name>Repository</name>
            <url>http://artifacts.com/rep</url>
            <releases>
               <enabled>true</enabled>
               <updatePolicy>always</updatePolicy>
            </releases>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupId>com.project.rest</groupId>
            <artifactId>common</artifactId>
            <version>2.0.5</version>
        </dependency>

    </dependencies>

And I've got this error

Downloading: http://artifacts.com/rep/com/project/rest/common/2.0.5/common-2.0.5.pom
[WARNING] The POM for com.project.rest:common:jar:2.0.5 is missing, no dependency information available

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.154s
[INFO] Finished at: Tue Feb 03 06:58:35 BRT 2015
[INFO] Final Memory: 9M/152M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project server: Could not resolve dependencies for project org.server:
server:jar:2.5.1-SNAPSHOT: The following artifacts could not be resolved: com.project.rest:common:jar:2.0.5:
Could not find artifact com.project.rest:common:jar:2.0.5 in rep (http://artifacts.com/rep) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

P.S I hid all real urls and package.

Basically it shows that it is able to download .pom but also it displays warning.

What's the problem?


回答1:


The first line "Downloading:..." only says that maven tries to download the artifact. It is no statement about success. If maven is successful you will get another line starting with "Downloaded: ..."

So in your case maven was not able to download the file. Check the logged url in your browser if it does exist and if it is protected.

BTW <updatePolicy>always</updatePolicy> is quite uncommon for release repos, because releases should not change any more.




回答2:


Make sure your repository is configured properly. Try to search, in your repo, for com.project.rest:common of version 2.0.5.

Is this your own project? some jar that you have built? are you sure you deployed it to your repo? if it is not in your repo, try to search for it in your local repo (usually .m2/repository/com/project...)




回答3:


DependencyResolutionException

(source: Maven Confluence)

This error generally occurs when Maven could not download dependencies. Possible causes for this error are:

  1. The POM misses the declaration of the <repository> which hosts the artifact.
  2. The repository you have configured requires authentication and Maven failed to provide the correct credentials to the server. In this case, make sure your ${user.home}/.m2/settings.xml contains a <server> declaration whose <id> matches the <id> of the remote repository to use. See the Maven Settings Reference for more details.
  3. The remote repository in question uses SSL and the JVM running Maven does not trust the certificate of the server.
  4. There is a general network problem that prevents Maven from accessing any remote repository, e.g. a missing proxy configuration.
  5. You have configured Maven to perform strict checksum validation and the files to download got corrupted.
  6. Maven failed to save the files to your local repository, see LocalRepositoryNotAccessibleException for more details.
  7. In Maven 3 if you just had a failed download and have fixed it (e.g. by uploading the jar to a repository) it will cache the failure. To force a refresh add -U to the command line.

In case of a general network-related problem, you could also consult the following articles:

  • Configuring a Proxy
  • Security and Deployment Settings
  • Guide to Remote Repository Access through Authenticated HTTPS



回答4:


The project you mentioned doesn't contains POM i.e. it is not a MAVEN project. The .m2(look this at c drive or where you have installed) repository contains all the dependencies folders look there whether it contains the required project or not i.e. com.project.rest.



来源:https://stackoverflow.com/questions/28296181/maven-cant-find-dependencies-dependencyresolutionexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!