我刚刚从subversion导入了一个项目到IntelliJ IDEA 11——这是一个maven项目。但是我在maven库依赖关系中有一个问题,所以我不能自动包括所有maven依赖关系- IDEA只在我打开该类时显示依赖错误/这就是我在这里得到的:

所以我想要自动添加所有依赖项-这是可能的还是我必须遍历所有类文件来识别和添加maven依赖项?!

更新:在做了一些修改之后,我发现了如何以某种方式解决我的问题。我就是这么做的:

但我认为从逻辑上讲,它不会包括和检查新的依赖关系?!在intelliJ - auto export dependencies to classpath中是否有设置区域?


当前回答

我还补充了一下对我有用的东西:

进入IDE右侧边缘的Maven Projects侧栏,验证您的依赖项是否在模块下面正确列出。假设它们是,只需让IDEA重新导入(顶部的第一个按钮,看起来像两个蓝色箭头组成一个逆时针圆圈)。

一旦我这样做了,并让IDEA为我重新加载项目,我所有的依赖关系就神奇地被理解了。

作为参考:这是与IDEA 13.1.2

其他回答

打开IntelliJ Idea,转到 文件>其他设置>默认设置…> Maven (Preferences) >导入或| 首选项> Maven >导入

单击控制台中的Enable Auto-import。

我通过使用正确的镜像配置更新我的settings.xml文件解决了这个问题,似乎每次导入maven模块时,intellij都会尝试从存储库下载元数据。

重新导入maven -> close-intellij ->删除全部 -。Idea-folder ->重新打开项目-> build- > build-project/build-module-'your parent module'

我能够通过在pom.xml文件中的构建标记后添加这行代码来修复我的问题,我从我的运行项目中进行比较,发现这是不同的,现在我都很好。

<repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
    </pluginRepositories>

在我的例子中,其中一个模块由于某种原因被忽略了。 要解决这个问题:右键单击有问题的模块并选择“取消忽略项目”。