栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

为什么“ MVN编译”需要“测试罐”依赖项

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

为什么“ MVN编译”需要“测试罐”依赖项

在我看来,这似乎是个确定的错误。

我有同样的问题,并测试了Maven 3.0.1和3.0.2。验证不会失败,只有编译步骤会失败。随着Maven 3

mvn compile
休息,但
mvntest-compile
可以。

看起来编译阶段正在反应器中寻找测试罐工件,然后在仓库中进行回购,但不应这样做,因为依赖项在测试范围内。测试范围工件应在测试编译而不是编译期间解决。

结果,我认为可以通过将Maven-compiler-plugin的testCompile目标映射到编译阶段而不是默认的test-compile阶段来解决。

我将其添加到pom中,紧接在上游pom中添加测试罐创建的部分旁边:

  <!-- there is a bug in maven causing it to resolve test-jar types       at compile time rather than test-compile. Move the compilation        of the test classes earlier in the build cycle -->  <plugin>    <artifactId>maven-compiler-plugin</artifactId>    <executions>      <execution>        <id>default-testCompile</id>        <phase>compile</phase>        <goals>          <goal>testCompile</goal>        </goals>      </execution>    </executions>  </plugin>

但这也不起作用,因为在编译和测试-编译之间的五个阶段都没有运行并设置诸如测试类路径之类的东西。

我猜在修正此错误之前,真正的解决方法是使用

test-compile
代替
compile



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/414439.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号