【问题标题】:IntelliJ maven project import issuesIntelliJ maven 项目导入问题
【发布时间】:2014-09-18 22:45:57
【问题描述】:

我是 IntelliJ 的新手。我想导入现有的 Maven 项目。

我已经完成了:

File->Import Project...->[selected pom.xml]->Finish...

项目被导入,我可以看到所有文件。在左下角写着Resolving dependencies of [project name]。过了一段时间就完成了。问题是,我的项目中没有 Maven 库。

更有趣的是,IntelliJ 为 maven 存储库 (.m/repository/) 中的库创建了所有文件夹结构,但它们都是 EMPTY。 我开始调查,看起来我的 pom.xml 有问题,但我不知道为什么。 例如

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.2.0.RELEASE</version>
</dependency>

被标记为错误:Dependency "org.springframework:spring:core:3.2.0.RELEASE" not found.

我的所有其他依赖项都是一样的。我错过了什么吗?

更新

我检查了 Maven 存储库设置,并且 本地 存储库设置正确。但是 Remote 存储库可能存在问题。当我单击它然后单击“更新”时,出现错误。 网址是http://repo.maven.apache.org/maven2

【问题讨论】:

  • 确保在 Setting->maven->repositories 下指定了本地存储库
  • 是的。正如我所写,它甚至在那里创建了库文件夹结构,例如org/springframework/spring-core/3.2.0.RELEASE,但它是空的

标签: java maven intellij-idea


【解决方案1】:

您需要告诉 maven 从哪里获取存储库。 您需要指定库所在的 Maven 远程(或本地)存储库。 在这种情况下,我想您需要添加以下内容:

    <repositories>
        <repository>
            <id>central maven repo</id>
            <url>http://central.maven.org/maven2</url>
        </repository>
    </repositories>

【讨论】:

  • 看来我的问题是 settings.xml 文件错误。结果表明,对于我正在从事的项目,我们有专门的存储库。谢谢,因为您的回答实际上是正确的:)
猜你喜欢
  • 1970-01-01
  • 2017-07-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-07
  • 2012-09-23
相关资源
最近更新 更多