intellij-idea - Intellij idea 12.0.4 中的依赖管理问题

标签 intellij-idea dependency-management

我在修改 Intellij12.04 中的依赖项时遇到问题。

在我的项目文件夹下,我有两个模块,其中第二个依赖于第一个:

  • a.b.c.somebusiness
    ---> a.b.c.tests

  • 我想从 a.b.c.tests 中删除一个依赖项并将其添加到 a.b.c.somebusiness 模块中,但我不想创建一个循环依赖项树。当我尝试从 a.b.c.tests 模块中删除依赖项并将其添加到 a.b.c.somebusiness 模块中时,我收到以下错误:

    "源根目录 "C:\Perforce\depot\Projest\Main\a.b.c.tests\src\test"不能在模块 "Main"中定义,因为它属于嵌套模块 "a.b.c.tests"的内容"

    我不知道该怎么做才能解决这个问题。谁能建议一种方法来解决我收到的错误?

    最佳答案

    你应该看看使用 apache maven和项目对象模型(pom.xml 文件)

    当您在 <dependencies> 下定义依赖项时在 pom.xml 中,它们由 IntelliJ 自动管理。因此,手动将依赖项移动到文件夹中,您将永远不会遇到此类问题。

    如果您按照如下所示的方式对其进行配置,您的依赖项将自动运行。

        <dependencies>
            <dependency>
                <groupId>a.b.c</groupId>
                <artifactId>a-b-c-tests</artifactId>
            </dependency>
            <dependency>
                <groupId>some.other.org</groupId>
                <artifactId>some.other.dep</artifactId>
            </dependency>
        </dependencies>
    

    如何开始:安装 apache maven 并在项目的根目录添加 pom.xml。右键单击它以将其添加为 IntelliJ 中的 maven 文件。

    祝你好运!

    关于intellij-idea - Intellij idea 12.0.4 中的依赖管理问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15909816/

    相关文章:

    java - Android Studio 无法运行项目 - 错误 :Execution failed for task ':app:preDexDebug' .

    java - 通过 IntelliJ 运行配置运行 Spring boot

    eclipse - 如何在Eclipse中将来自Maven Central等的库添加到现有的非Gradle,非Maven项目

    ruby:如何正确要求(避免循环依赖)

    maven - Gradle中的Maven父POM依赖管理

    gradle - 等价于 gradle 中测试依赖的 api

    intellij-idea - spring-boot 无法在 gradle build 上加载 liquibase 更改

    eclipse - Intellij IDEA模块默认 "user.dir"

    mercurial - Intellij 11.0.1 似乎忽略了我的 .hgignore 文件

    gradle - 无法使用Gradle从Maven Central获取水 jar 2.0.0