gpt4 book ai didi

java - Maven 带来 "test"传递依赖为 "compile"

转载 作者:搜寻专家 更新时间:2023-10-31 19:55:03 26 4
gpt4 key购买 nike

当我为我的项目运行“mvn dependency:tree”时,它显示如下:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ xxxxx ---
[INFO] com.xxx.xxx:xxxxx:war:3.1.0-SNAPSHOT
...
[INFO] +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-api:jar:2.34.0:test
[INFO] | +- com.google.guava:guava:jar:14.0:test
[INFO] | \- org.json:json:jar:20080701:test
[INFO] +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.34.0:test
[INFO] | +- org.seleniumhq.selenium:selenium-remote-driver:jar:2.34.0:test
[INFO] | | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | | \- net.java.dev.jna:platform:jar:3.4.0:test
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.12:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.1:test
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.2.3:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.12:test
[INFO] | +- xerces:xercesImpl:jar:2.10.0:test
>>>[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.18:test
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.9:test
[INFO] | | \- org.w3c.css:sac:jar:1.3:test
[INFO] | \- org.eclipse.jetty:jetty-websocket:jar:8.1.9.v20130131:test
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.34.0:test
...

正如您在标记行中看到的,xml-apis 具有“编译”范围,因此它被打包到 .war 文件中。为什么会发生?

更有趣的是,它仅在使用 Java5 时发生,对于 Java6,依赖项显示为“测试”。

Maven 版本:3.0.4

最佳答案

研究以下 Maven 命令的输出。

mvn -X dependency:tree -Dverbose

这应该告诉您为什么 Maven 将范围从测试升级到编译。

关于java - Maven 带来 "test"传递依赖为 "compile",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24579236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com