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

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

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

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


当前回答

如果其他方法都失败了,请检查本地.m2存储库中的jar文件是否确实有效且没有损坏。在我的例子中,文件还没有完全下载。

其他回答

我有一个类似的问题,在我的情况下,我正在使用一个自定义设置。xml,这不是从IntelliJ选择。

解决方案: 文件>设置>构建,执行,部署> Maven:用户设置文件(在这里选择我的自定义Settings .xml)。

我的macbook也有类似的问题,只是在pom.xml中做了一个小更改,它开始下载所有依赖项:

我的windows机器的早期依赖项如下所示:

<dependencies>
 <dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>1.4</version>
</dependency>
</dependencies>

我只是删除了<dependencies>和</dependencies>标签,它开始下载所有依赖项:

<dependency>
  <groupId>javax.mail</groupId>
  <artifactId>mail</artifactId>
  <version>1.4</version>
</dependency>

我不确定它是否适合你。但对我来说很好。

谢谢

我遇到了同样的问题,尝试了所有建议的方法,但都没有解决问题,我使用的是Intellij 13.1.3版

最后,在花了几个小时试图修复它之后,我决定尝试升级版本,并在14.1.4版本中打开项目,最终解决了这个问题。我认为这可能是前一个版本的bug。

我希望这能有所帮助!

From maven tab click + and choose pom.xml From maven tab click download sources and documentation On project structure(where you can view project files/directories) right click the project you're trying to build and choose Build Module Project Name. From tab Run- Edit Configurations with + add Application and fill the below fields: i. Main Class- Manually choose from Project tab select the main class ii. Use classpath of module - choose the application name iii. Shorten command line - classpath file Now simply run the app.

如果某些maven模块没有编译,检查它们的pom.xml是否在“被忽略的文件”列表中。在IntelliJ goto

首选项->项目设置-> maven ->忽略文件

并检查是否忽略了相关的pom.xml。