gpt4 book ai didi

java - 带有 apache Ivy 依赖管理的 Log4j2 无法解析 log4j-api-java9

转载 作者:搜寻专家 更新时间:2023-11-01 00:54:17 25 4
gpt4 key购买 nike

当尝试将 apache log4j2 与 ivy 构建管理工具一起使用时,我在尝试解析依赖项时遇到以下错误:

:: problems summary ::
:::: WARNINGS
module not found: org.apache.logging.log4j#log4j-api-java9;2.11.0
==== local: tried
C:\Users\Scott Neville\.ivy2\local\org.apache.logging.log4j\log4j-api-java9\2.11.0\ivys\ivy.xml
-- artifact org.apache.logging.log4j#log4j-api-java9;2.11.0!log4j-api-java9.zip:
C:\Users\Scott Neville\.ivy2\local\org.apache.logging.log4j\log4j-api-java9\2.11.0\zips\log4j-api-java9.zip
==== shared: tried
C:\Users\Scott Neville\.ivy2\shared\org.apache.logging.log4j\log4j-api-java9\2.11.0\ivys\ivy.xml
-- artifact org.apache.logging.log4j#log4j-api-java9;2.11.0!log4j-api-java9.zip:
C:\Users\Scott Neville\.ivy2\shared\org.apache.logging.log4j\log4j-api-java9\2.11.0\zips\log4j-api-java9.zip
==== public: tried
https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api-java9/2.11.0/log4j-api-java9-2.11.0.pom
-- artifact org.apache.logging.log4j#log4j-api-java9;2.11.0!log4j-api-java9.zip:
https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api-java9/2.11.0/log4j-api-java9-2.11.0.zip
module not found: org.apache.logging.log4j#log4j-core-java9;2.11.0
==== local: tried
C:\Users\Scott Neville\.ivy2\local\org.apache.logging.log4j\log4j-core-java9\2.11.0\ivys\ivy.xml
-- artifact org.apache.logging.log4j#log4j-core-java9;2.11.0!log4j-core-java9.zip:
C:\Users\Scott Neville\.ivy2\local\org.apache.logging.log4j\log4j-core-java9\2.11.0\zips\log4j-core-java9.zip
==== shared: tried
C:\Users\Scott Neville\.ivy2\shared\org.apache.logging.log4j\log4j-core-java9\2.11.0\ivys\ivy.xml
-- artifact org.apache.logging.log4j#log4j-core-java9;2.11.0!log4j-core-java9.zip:
C:\Users\Scott Neville\.ivy2\shared\org.apache.logging.log4j\log4j-core-java9\2.11.0\zips\log4j-core-java9.zip
==== public: tried
https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core-java9/2.11.0/log4j-core-java9-2.11.0.pom
-- artifact org.apache.logging.log4j#log4j-core-java9;2.11.0!log4j-core-java9.zip:
https://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core-java9/2.11.0/log4j-core-java9-2.11.0.zip
::::::::::::::::::::::::::::::::::::::::::::::
:: UNRESOLVED DEPENDENCIES ::
::::::::::::::::::::::::::::::::::::::::::::::
:: org.apache.logging.log4j#log4j-api-java9;2.11.0: not found
:: org.apache.logging.log4j#log4j-core-java9;2.11.0: not found
::::::::::::::::::::::::::::::::::::::::::::::
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
C:\Users\Scott Neville\Documents\fh\running_app\backend\build.xml:77: impossible to resolve dependencies:

这是使用 ivy.xml 的:

<ivy-module version="2.0">
<info organisation="uk.co.worldsofwar" module="sipsoc"/>
<dependencies>
<dependency org="org.eclipse.jetty" name="jetty-http" rev="9.4.9.v20180320"/>
<dependency org="org.eclipse.jetty" name="jetty-annotations" rev="9.4.9.v20180320" />
<dependency org="org.eclipse.jetty" name="jetty-webapp" rev="9.4.9.v20180320" />
<dependency org="org.freemarker" name="freemarker" rev="2.3.28" />
<dependency org="org.glassfish.jersey.core" name="jersey-server" rev="2.27" />
<dependency org="org.glassfish.jersey.containers" name="jersey-container-servlet" rev="2.27" />
<dependency org="org.glassfish.jersey.media" name="jersey-media-json-jackson" rev="2.27" />
<dependency org="com.auth0" name="java-jwt" rev="3.3.0" />
<dependency org="com.zaxxer" name="HikariCP" rev="3.1.0" />
<dependency org="org.postgresql" name="postgresql" rev="42.2.2" />
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.11.0" />
<dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.11.0" />



<exclude org="*" ext="*" type="source" />
<exclude org="*" ext="*" type="javadoc" />
<exclude org="*" ext="*" type="tests" />

</dependencies>
</ivy-module>

游戏中没有特殊的 ivysettings.xml,只有从公共(public)存储库中收集的默认设置。依赖解析是通过 ant 完成的,只是使用一个非常标准的 . Java 运行时是版本 8(JDK 也是)。

最佳答案

添加依赖配置以从测试依赖中分离构建解决了我的问题:

ivy.xml

<configurations>
<conf name="build" description="development dependencies"/>
<conf name="test" extends="build" visibility="private" description="testing dependencies"/>
</configurations>

<dependencies>
<dependency org="org.apache.commons" name="commons-lang3" rev="3.9" conf="build->default"/>
<dependency org="org.apache.logging.log4j" name="log4j-core" rev="2.11.1" conf="build->default"/>
<dependency org="org.apache.logging.log4j" name="log4j-api" rev="2.11.1" conf="build->default"/>

<dependency org="junit" name="junit" rev="4.12" conf="test->default"/>
<dependency org="org.hamcrest" name="hamcrest" rev="2.1" conf="test->default"/>
</dependencies>

build.xml中解决依赖关系:

<target name="resolve" depends="init-ivy" description="resolve project dependencies">
<ivy:resolve file="${ivy.file}"/>
<ivy:retrieve sync="true" type="jar, bundle" pattern="lib/[conf]/[artifact].[ext]"/>
</target>

这会将依赖项放在一个文件夹结构中,便于 ant 独立编译测试和构建源:
./lib/build/
./lib/测试/

Example repository我将其用作模板

关于java - 带有 apache Ivy 依赖管理的 Log4j2 无法解析 log4j-api-java9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51467162/

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