Home > Blockchain >  Why does Maven randomly stop seeing dependencies and how do I make it?
Why does Maven randomly stop seeing dependencies and how do I make it?

Time:04-26

I have a Maven project using Jetty as a runner – in case it's relevant. My pom.xml file contains the following

<dependency>
    <groupId>org.elasticsearch.client</groupId>
    <artifactId>transport</artifactId>
    <version>7.17.3</version>
</dependency>

It used to be 7.14.2 and I upgraded it. After cleaning and refreshing, IntelliJ says some of the classes in one of the packages on which transport depends can't be found anymore. I tried forcing refreshes, cleaned the project multiple times, resolving dependencies... nothing, the project doesn't even build anymore because of those missing classes. I figured I'd downgrade it again, just in case I missed a breaking change somewhere but now I have the older version and the classes are still not there. I switched to a branch which I'm sure works and sure enough everything builds and runs just fine.

I checked with mvn dependency:tree and this is what comes up:

[INFO]  - org.elasticsearch.client:transport:jar:7.17.3:compile
[INFO] |   - org.elasticsearch:elasticsearch:jar:7.17.3:compile
[INFO] |  |   - org.elasticsearch:elasticsearch-core:jar:7.17.3:compile
[INFO] |  |   - org.elasticsearch:elasticsearch-secure-sm:jar:7.17.3:compile
[INFO] |  |   - org.elasticsearch:elasticsearch-x-content:jar:7.17.3:compile

elasticsearch-x-content is the package that is supposed to contain those classes and it shows up correctly (in the downgraded version too) but the classes are nowhere to be found.

I have had similar problems in the past where either Maven or IntelliJ IDEA randomly decide to stop seeing things that they were both happy to see just 20 minutes prior, and I never know how I manage to "fix" the issue each time so I don't have a repeatable series of incantations that I can offer as a clue.

Any ideas?

CodePudding user response:

Did you try running mvn compile from the command line and then refresing the project? Sometimes Intellij will bug out and not actually download a dependency even though it says it's trying to (happened to me a week ago).

CodePudding user response:

You can try to refresh the dependencies by using the maven plugin of IDEA.

enter image description here

  • Related