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

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

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

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


当前回答

3.3 IntelliJ 2020年。

这一个帮我做到了。

构建、执行、部署工具。

更改“在构建脚本中更改后重新加载项目”:

从默认的“外部更改”改为“任何更改”

有了这个,重建项目花了一段时间,但现在我可以看到IntelliJ中的Maven依赖项:

其他回答

如果在右下角显示“2个进程正在运行……”或类似的内容,您可能只需要等待它完成,因为下载所有的jar可能需要时间。

当你创建一个新项目时,你只需要选择以下选项:

... 从外部模型导入项目 在现有的外部模型(Eclipse, Maven…)上创建IDEA项目结构 ...

你会发现从那里开始就很简单了。 在您的情况下,您可以关闭您的项目,并简单地创建一个新项目。选择项目的目录,该目录将覆盖它,使其成为Maven项目。

我能够通过从项目设置->模块列表中删除不必要的模块来解决这个问题。

当我从项目文件夹导入IntelliJ项目时(而不是通过打开pom.xml),这些额外的模块是由IntelliJ IDEA自动创建的。然后,在将项目声明为Maven项目之后,创建了适当的模块,现有模块与之冲突。在项目创建期间也可以排除这些模块。

我能够通过在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>

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

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

谢谢