https://stackoverflow.com/questions/65849103/intellij-still-using-old-dependency
IntelliJ still using old dependency
Ask Question Asked 2 years ago Modified 2 years ago Viewed 2k times <iframe data-google-container-id="1" data-is-safeframe="true" data-load-complete="true" frameborder="0" height="90" id="google_ads_iframe_/248424177/stackoverflow.com/lb/question-pages_0" marginheight="0" marginwidth="0" scrolling="no" src="https://736094ca3736d7be144aecc800bc3941.safeframe.googlesyndication.com/safeframe/1-0-40/html/container.html" title="3rd party ad content" width="728"></iframe> 0I am currently using Intellij Idea 2020.2.4.
I want to replace a dependency with a newer version of itself. I replaced
<dependency>
<groupId>com.company.digital.fmk</groupId>
<artifactId>dgt-security</artifactId>
<version>2.6.24</version>
</dependency>
with
<dependency>
<groupId>com.company.digital.fmk</groupId>
<artifactId>dgt-security</artifactId>
<version>3.9.0</version>
</dependency>
I've checked that in the effective pom, the version has changed to the new value. However, after running mvn -U clean install
, when I click on a class from the dependency, it still shows the old version.
When I try to delete the old version from the project structure, it says that it is still used in a module, even though I can't find the old version number anywhere in the project.
I can't manually delete the old library from my local folder, because it is used in another project.
Other answers have suggested using Maven -> Reimport, but I didn't find this in my intellij
What can I do to make intellij use the new dependency version in my project ?
EDIT
When I right-click on a project and select Maven, here are my options:
- Reload project (already tried, did not work)
- Generate sources and update folders
- Ignore projects
- Unlink maven projects
- Open 'settings.xml'
- Create 'profiles.xml'
- Download sources
- Download documentation
- Download sources and documentation
- Show effective pom
- Show diagram
- Show diagram popup
- Going to ask the obvious question: why haven't you tried to remove the dependency from the POM directly? (Project Structure is built off of the POM, so it'd likely be recreated if you just deleted it from there within IntelliJ.) – Makoto Jan 22, 2021 at 16:59
- I did, sorry if that wasn't clear in my question. Please see my edit – l0r3nz4cc10 Jan 22, 2021 at 17:12
- You need to reimport inside IntelliJ. If you changed the POM, there should be refresh button hovering in the upper-right corner of the pom.xml, and otherwise you can reimport from the Maven tab. – Mark Rotteveel Jan 22, 2021 at 17:56
2 Answers
1You can go to your Maven repository: .m2/com/company/digital/fmk Delete jar files Rerun command, it will download dependencies again.
Share Edit answered Jan 22, 2021 at 17:20 bryantran 2611 bronze badge- Ok that worked, but can't it be automated ? – l0r3nz4cc10 Jan 22, 2021 at 17:39
- Looks like youtrack.jetbrains.com/issue/IDEA-255594. Does this problem remain every time you change this dependency version? Do you see it only with this dependency? – Andrey Jan 24, 2021 at 9:07
Right click on project -> maven -> sync shall do the trick previous versions did this by default on changes in pom.xml now it seems to be not available anymore
Share Edit answered Jan 22, 2021 at 16:36 Konstantin Pribluda 12.3k11 gold badge2929 silver badges3535 bronze badges- Hello, please see my edit: I don't have the sync entry... – l0r3nz4cc10 Jan 22, 2021 at 16:53
- File - invalidate caches / restart ? Your dependency is the same version, or a new one? – Konstantin Pribluda Jan 22, 2021 at 17:00