【问题标题】:Maven not importing External Library into project after adding to .pom file in Intellij在 Intellij 中添加到 .pom 文件后,Maven 未将外部库导入项目
【发布时间】:2019-03-17 17:44:23
【问题描述】:

我无法将库正确导入到我正在运行的项目中。我已将库作为依赖项添加到 .pom 中,刷新了 pom,运行 mvn clean install,并设置了 auto-import,以便项目正确更新,但项目未添加为外部库,我不能在我的项目中使用它。我没有错误。我做错了什么?

这是我的 pom 的相关部分

 ..properties
 <crowd.version>2.5.0</crowd.version>
 .. end properties

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.atlassian.crowd</groupId>
        <artifactId>crowd-integration-springsecurity</artifactId>
        <version>${crowd.version}</version>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
</dependencyManagement>

这是我调试错误时所遵循的问题: Import Maven dependencies in IntelliJ IDEA

【问题讨论】:

  • 没什么,很遗憾
  • 这个依赖关系是在 maven Central 还是您在 settings.xml 中引用的任何其他 repo 中。 mvnrepository.com 显示了一些疯狂的依赖版本:-)。
  • @CrazyCoder 根据您的建议,我尝试了compiletest,但没有奏效。

标签: maven intellij-idea


【解决方案1】:

我认为您错过了依赖管理的要点;在official docs 中阅读更多内容。这是一项功能,您可以集中公共依赖信息,然后将这些信息共享给不同的项目。就其本身而言,此定义将不会导入依赖项。

您可能想要的只是一个简单的依赖项:删除 dependencyManagement 标记,并将您的依赖项移动到 pom 中的正确块中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-15
    • 1970-01-01
    • 2016-07-20
    • 2021-01-15
    • 1970-01-01
    相关资源
    最近更新 更多