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

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

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

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


当前回答

这个问题的一个可能的模式是,你没有连接到Nexus,基本上你想在离线模式下构建项目。但是当您导入项目时,Idea会尝试自动下载Maven依赖项。和失败。您在设置中设置了脱机工作复选框,但为时已晚:在首次下载尝试中已经出现故障。这里列出的两个选项都不能解决这个问题。相反,我做了以下事情:

第一个创建空Java(不是Maven)项目 选中Maven设置中的离线工作选项 将我的项目作为Maven模块添加到这个新项目中

这样就成功了。

其他回答

我在IntelliJ 2016.3.X中遇到了一些子依赖无法解决的问题。这可以通过在设置>构建,执行,部署>构建工具> Maven中更改Maven主目录从捆绑(Maven 3)到/usr/share/ Maven来修复。

在此之后,所有子依赖项都像以前的IntelliJ版本一样得到解决。

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

我的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>

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

谢谢

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 -> close-intellij ->删除全部 -。Idea-folder ->重新打开项目-> build- > build-project/build-module-'your parent module'