When I manually add dependencies in the pom.xml of my project, let Maven download the dependencies and let IntelliJ build the module, IntelliJ complains about missing libraries. At the same time Maven can find the dependent JARs and build the project.
How can I tell IntelliJ to use the libs which are downloaded by Maven?
This question is related to
maven
intellij-idea
Approach 1
File > Settings... > Build, Execution, Deployment > Build Tools > Maven > Importing > check Import Maven projects automatically
Approach 2
Approach 1
Approach 2
For some reason IntelliJ (at least in version 2019.1.2) ignores dependencies in local .m2
directory. None of above solutions worked for me. The only thing finally forced IntelliJ to discover local dependencies was:
pom.xml
(not on a project directory)Open as Project
Delete Existing Project and Import
Apart from checking 'Import Maven projects automatically', make sure that settings.xml file from File > Settings > Maven > User Settings file exist, If doesn't exist then override and provide your settings.xml file path.
It turns out IntelliJ does not pick up added dependencies from the local Maven repository. We have to tell IntelliJ to reimport the pom.xml.
in IntelliJ 2020 in the pom.xml
view one should be able to apply pom changes by following key combination: CTRG + SHIFT + O.
And as correctly commented before - IntelliJ additionally shows a balloon widget to import changes.
Uncheck
"Work Offline"
in Settings -> Maven ! It worked for me ! :D
File>Settings>Build,Execution,Deployment>Maven> Check : Always update snapshot
That worked for me.
Source: Stackoverflow.com