Reputation: 1031
I have the current version of the dependency successfully installed in the local mvn .m2
registry with mvn clean install
(confirmed by cd into .m2
repository).
I then modified the pom.xml
of the project to include the new version number:
<dependency>
<groupId>com.xyz.lib</groupId>
<artifactId>xyz-lib-abc-model</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
Maven was able to build successfully with 1.4.0-SNAPSHOT
, but when I accessed the project in IntelliJ, it linked to an old version (0.1.1-SNAPSHOT
) instead of the current version.
When I checked the dependency tree using `mvn dependency:tree, I have:
[INFO] +- com.xyz.lib:xyz-lib-abc-model:jar:1.4.0-SNAPSHOT:compile
Which looks correct to me.
I have tried using <dependencyManagement>
but then it makes the project failed to build, and failed to detect the model.
Anyone knows what's going on and how to get maven to pull the correct version?
Thank you in advance!
Upvotes: 0
Views: 2109
Reputation: 222
my first guess goes to the used maven type in your IDEA is not the one that you use in the terminal. :)
You can set up the installed maven instead of the bundled one.
Or another solution is that you proceed a “refresh/reimport” in pom.xml. It will investigate the classpath based on your pom.xml and refresh the ones that needed.
You should see the "Reimport button here
If you don't see Maven at all, that means. you haven't added your project to IDEA as a Maven project.
Please then do the following
1. Right Click on pom.xml
2. 2. Add as a maven project
Upvotes: 0
Reputation: 42541
Try the following approach:
DependencyManagement section is irrelevant in this case - mention it because you've said in the question that you've tried this - so don't bother, it will save you some time :)
Upvotes: 0
Reputation: 6226
Try re-importing the dependencies from local m2 in IntelliJ like :
Upvotes: 2
Reputation: 194
I have seen this issue with IntelliJ. If you don't need the old version anymore, you can cd to .m2 directory and delete the older version manually. But you need to keep the both versions, you can open the project as a fresh project using the pom.xml. This will solve the issue.
Upvotes: 0