我的应用程序仅更改了存储库的链接URL后就拒绝编译。
想要从nexus1迁移到nexus3,将设置所有Maven代理,并上传所有内部工件。一切似乎都很好。直到它只是拒绝编译,而没有其他任何代码更改。
error: package org.apache.log4j does not exist
import org.apache.log4j.LogManager;
^
这很奇怪,因为它实际上下载了log4j工件,并且在将链接更改回nexus1之后,一切再次正常。比较了两个关系下载的两组人工制品,它们完全相同。
此外,log4j首先出现在之后的路径上
./gradlew dependencies
调试后会显示:
[DEBUG] [ComponentAttributeMatcher] Selected match org.apache.logging.log4j:log4j-core:2.8.2 configuration default from candidates [org.apache.logging.log4j:log4j-core:2.8.2 configuration default] for {org.gradle.usage=java-api}
[DEBUG] ComponentAttributeMatcher] Selected match org.apache.logging.log4j:log4j-slf4j-impl:2.8.2 configuration default from candidates [org.apache.logging.log4j:log4j-slf4j-impl:2.8.2 configuration default] for {org.gradle.usage=java-api}
[DEBUG] [ComponentAttributeMatcher] Selected match org.apache.logging.log4j:log4j-api:2.8.2 configuration default from candidates [org.apache.logging.log4j:log4j-api:2.8.2 configuration default] for {org.gradle.usage=java-api}
[DEBUG] [ComponentAttributeMatcher] Selected match org.apache.logging.log4j:log4j-api:2.8.2 configuration runtime from candidates [org.apache.logging.log4j:log4j-api:2.8.2 configuration runtime] for {org.gradle.usage=java-api}
这是正确的版本。
我对更改链接URL会如何影响应用程序的编译感到很困惑?
我们还进行依赖替换,因为该应用程序很大,这有助于从log4j1迁移到log4j2
substitute module('log4j:log4j') with module("org.apache.logging.log4j:log4j-1.2-api:${log4jVersion}")