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 ?
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.
You don't have to reimport manually each time. You can enable auto-import as documented here. Change this in Settings -> Maven -> Import Maven projects automatically.
Approach 1
File > Settings... > Build, Execution, Deployment > Build Tools > Maven > Importing > check Import Maven projects automatically
Approach 2
Approach 1
Approach 2
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.
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
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.
除了检查“自动导入 Maven 项目”之外,请确保文件 > 设置 > Maven > 用户设置文件中的 settings.xml 文件存在,如果不存在,则覆盖并提供您的 settings.xml 文件路径。
I tried absolutely everything to get IntelliJ to pickup my pom.xml
changes but it just wasn't doing it. I commented out all of the <dependencies>
in pom.xml
and rebuilt the project which should've shown hundreds of compile errors but didn't.
In the end, I had to delete the .idea
folder to get IntelliJ to regenerate it's maven model. Once I did this, subsequent changes to pom.xml
were picked up when I did a "Reload All Projects" so I suspect a bug where IntelliJ is using a cached model rather than updating it when changes are made.
Here's what I did:
.idea
folder in the root folder of the project
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.