【问题标题】:Dependency to project foo with type test-jar is not fully supported.不完全支持对 test-jar 类型的项目 foo 的依赖。
【发布时间】:2013-01-14 14:48:59
【问题描述】:

在我的 maven 项目中,我使用了 m2e 不喜欢的 test-jar 类型的依赖项,并给出了以下警告。

"对 test-jar 类型的项目 foo 的依赖不完全 支持的。可能会出现类路径和/或部署问题。尝试 Maven->禁用工作区”

为什么会出现这个问题,为什么禁用工作区分辨率会解决这个问题?

【问题讨论】:

    标签: eclipse maven m2e


    【解决方案1】:

    test-jar 的问题出在 Eclipse 中,请参阅 Bug 365419 - Classpath for Integration Test

    【讨论】:

    • 感谢您指出问题所在,但您知道有什么解决方法吗?
    【解决方案2】:

    我已经尝试使用下面的 hack 来消除此警告,但是它有一个副作用,即无法从 eclipse 运行测试,因为运行代码未正确设置时 eclipse 中的测试的类路径.我在这里发帖是希望有人可以改进这个黑客并使其发挥作用。

    在 pom 文件中创建配置文件在 eclipse 中关闭,但在 eclipse 外运行 maven 时自动开启。

    <profiles>
            <profile>
                <id>test-jars</id>
                <activation>
                    <property>
                        <name>!m2e.version</name>
                    </property>
                </activation>
                <dependencies>
                    <dependency>
                        <groupId>com.example</groupId>
                        <artifactId>foo</artifactId>
                        <version>${project.version}</version>
                        <type>test-jar</type>
                        <scope>test</scope>
                    </dependency>
                    <dependency>
                        <groupId>com.example</groupId>
                        <artifactId>bar</artifactId>
                        <version>${project.version}</version>
                        <type>test-jar</type>
                        <scope>test</scope>
                    </dependency>
                </dependencies>
            </profile>
        </profiles>
    

    在 Eclipse 中定义了 m2e.version 属性,因此 m2e 会忽略 test-jar 依赖项,并且不会生成警告。但是,在命令行上运行 maven 时,配置文件会激活,因为没有 m2e.version 属性,因此警告消失了。

    【讨论】:

      猜你喜欢
      • 2017-06-09
      • 2016-08-05
      • 2019-06-21
      • 1970-01-01
      • 2016-12-21
      • 1970-01-01
      • 2019-08-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多