本文介绍了在Grails 2.4中更新log4j导致"无法将项目从grailsCentral"传输到grailsCentral"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将我的Grails 2.4.2安装中的log4j更新到最新版本。

我在BuildConfig.groovy中指出了这一点

dependencies {
    ... 
    compile 'org.apache.logging.log4j:log4j:2.17.1'
}

存储库部分如下所示:

repositories {
    inherits true // Whether to inherit repository definitions from plugins

    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    //mavenCentral()
    
    mavenRepo 'https://repo1.maven.org/maven2/'
    mavenRepo 'https://repo.maven.apache.org/maven2/'
    mavenRepo 'https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j'
    //uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
    //mavenRepo "http://repository.codehaus.org"
    //mavenRepo "http://download.java.net/maven/2/"
    //mavenRepo "http://repository.jboss.com/maven2/"        
}

我已经尝试取消对所有已注释的回复的注释。我还添加了Maven页面中指示的存储库(如图所示)。

每次我尝试生成项目时,都会失败,并显示以下错误:

Error |
Resolve error obtaining dependencies: Could not transfer artifact 
org.apache.logging.log4j:log4j:jar:2.17.1 from/to grailsCentral 
(http://repo.grails.org/grails/plugins): Permanent Redirect (308) (Use --stacktrace 
to see the full trace)

我第一次尝试生成时,下载了项目,然后失败,出现上述错误。

运行grails dependency-report --stacktrace会产生以下结果:

Resolve error obtaining dependencies: Could not transfer artifact org.apache.logging.log4j:log4j:jar:2.17.1 from/to grailsCentral (http://repo.grails.org/grails/plugins): Permanent Redirect (308) (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
org.eclipse.aether.resolution.DependencyResolutionException: Could not transfer artifact org.apache.logging.log4j:log4j:jar:2.17.1 from/to grailsCentral (http://repo.grails.org/grails/plugins): Permanent Redirect (308)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
    at grails.util.BuildSettings.doResolve(BuildSettings.groovy:514)
    at grails.util.BuildSettings.doResolve(BuildSettings.groovy)
    at grails.util.BuildSettings$_getDefaultTestDependencies_closure16.doCall(BuildSettings.groovy:588)
    at grails.util.BuildSettings$_getDefaultTestDependencies_closure16.doCall(BuildSettings.groovy)
    at grails.util.BuildSettings.getDefaultTestDependencies(BuildSettings.groovy:582)
    at grails.util.BuildSettings.getTestDependencies(BuildSettings.groovy:563)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.apache.logging.log4j:log4j:jar:2.17.1 from/to grailsCentral (http://repo.grails.org/grails/plugins): Permanent Redirect (308)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
    ... 6 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.apache.logging.log4j:log4j:jar:2.17.1 from/to grailsCentral (http://repo.grails.org/grails/plugins): Permanent Redirect (308)
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
    ... 8 more
Caused by: org.apache.http.client.HttpResponseException: Permanent Redirect (308)
    at org.eclipse.aether.transport.http.HttpTransporter.handleStatus(HttpTransporter.java:458)
    at org.eclipse.aether.transport.http.HttpTransporter.execute(HttpTransporter.java:283)
    at org.eclipse.aether.transport.http.HttpTransporter.implGet(HttpTransporter.java:235)
    at org.eclipse.aether.spi.connector.transport.AbstractTransporter.get(AbstractTransporter.java:59)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$GetTaskRunner.runTask(BasicRepositoryConnector.java:447)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
    ... 13 more

有什么想法吗?可能GrasCentral更改了URL?

推荐答案

可能我误解了,但我正在使用:

compile "org.apache.logging.log4j:log4j-core:2.17.1"
compile "org.apache.logging.log4j:log4j-api:2.17.1"

这就是你想要做的吗?也许基本版本是对此的一种速记,只是一些可以尝试的东西

这篇关于在Grails 2.4中更新log4j导致"无法将项目从grailsCentral"传输到grailsCentral"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 16:30