简体   繁体   中英

Eclipse not able to resolve Maven dependency

I have been working on a Java Maven project and my way of using it in Eclipse was to build it on command line and then import in Eclipse. The problem that I was facing is even though the project built successfully, eclipse was not able to resolve dependencies correctly.

This problem would usually go by cleaning, Maven updating and deleting and importing. However, this time it did not get resolved by following these steps. I tried a lot of already existing answers but nothing worked for me. However, I observed that the classpath is not getting created correctly:

Java构建路径

I'm seeing that one of the dependency jars is marked as missing

I tried to create the Eclipse .classpath file using:

mvn eclipse:clean
mvn eclipse:eclipse

But mvn eclipse:eclipse fails with the following message:

Failed to execute goal on project consultation: Could not resolve dependencies for project company.compliance:consultation:jar:1.0-SNAPSHOT: Failure to find company.compliance:commons:jar:1.0-SNAPSHOT in http://maven.ia55.net/company was cached in the local repository, resolution will not be reattempted until the update interval of company-mvn-repository has elapsed or updates are forced -> [Help 1]

I read in some of the answers that this can also happen if m2e is not configured properly (it should be pointing to the commandline maven and not embedded maven). When I checked I saw that I don't even have m2e so in installed it. I don't know how to configure it to point to my Maven.

However, I doubt that this problem is because of the plugin not working otherwise I would not have been able to work in Eclipse peacefully till now.

So my other question is, isn't the success of mvn clean package enough to warrant that eclipse should not have any compilation errors regarding dependencies or does scope of dependency also plays a role and that I should work on getting the jar in the repo.

Is there any other possible issue that I am missing?

The issue got resolved. Earlier i was only importing the project that i wanted to work on. After importing all the projects in the directory which contained the pom, eclipse resolved the dependencies. Have no clue how this worked but it did.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM