Import Maven dependencies in IntelliJ IDEA

2019-01-03 08:18发布

I have a small question about IntelliJ IDEA 11. I just imported a project from subversion - its a maven project. But I have a problem in maven library dependencies so that I can't include all maven dependencies automatically - IDEA shows dependency errors only when I open that class/ Thats what I get here:

enter image description here

So I want all dependencies to be added automatically - is that possible or do I have to go through all class files to identify and add maven dependencies?!

UPDATE: After doing some modifications I found how to resolve my problem in some way. Thats what I did: enter image description here

but I think logically it will not include and check new dependencies ahead?!... Is there any settings area for this in intelliJ - auto export dependencies to classpath ?!

27条回答
贪生不怕死
2楼-- · 2019-01-03 08:20

Maven - Reimport did not work for me. I have Spring project in STS(Eclipse) and my solution is to import project to IDEA like so:

1) File - New - Project from Existing Sources... - select directory - choose Eclipse.
2) Set Maven autoimport to true in settings.
3) Then right click in pom.xml and choose Add as Maven Project.

After this it has imported everything.

查看更多
三岁会撩人
3楼-- · 2019-01-03 08:22

When importing the project, select pom.xml instead of the project directory. It should work.

查看更多
祖国的老花朵
4楼-- · 2019-01-03 08:22

Nothing worked for me until I tried "File --> Open" and then navigated to the POM file itself.

查看更多
叛逆
5楼-- · 2019-01-03 08:24

What helped me:

Navigage: Settings | Build, Execution, Deployment | Maven

Specify "Maven home directory" - the place you installed the maven

查看更多
The star\"
6楼-- · 2019-01-03 08:24

Reimport the project. If you install maven plugin you can use this.

Right click on the project -> Maven -> Reimport

查看更多
放我归山
7楼-- · 2019-01-03 08:24

First check path Specified for User Settings file: in Settings -> Build,Execution,Development -> Build Tools -> Maven . The field should have path of the settings.xml of your maven. Also the settings.xml should have correct path of remote repository.

查看更多
登录 后发表回答