gpt4 book ai didi

grails - spring-security-rest 和 guava 之间的间接 jar 冲突导致 NoSuchMethod 错误

转载 作者:行者123 更新时间:2023-12-02 05:10:58 36 4
gpt4 key购买 nike

我使用grails 3.1.16

构建.gradle:

dependencies {
compile "com.google.guava:guava:18.0"
compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
}

运行此代码时:

   private LoadingCache<String, Boolean> attempts

@PostConstruct
void init() {
Integer time = ApplicationContextHolder.getProperty(ApplicationContextHolder.config.time)
attempts = CacheBuilder.newBuilder()
.expireAfterWrite(time, TimeUnit.MINUTES)
.build({ 0 } as CacheLoader)
}

我收到以下错误:

Caused by: java.lang.NoSuchMethodError: com.google.common.base.Platform.systemNanoTime()J
at com.google.common.base.LocalCache(Ticker.java:60)
at com.google.common.cache.LocalCache$Segment.put(LocalCache.java:2827)
at com.google.common.cache.LocalCache.put(LocalCache.java:4149)
at com.google.common.cache.LocalCache$LocalManualCache.put(LocalCache.java:4754)
at com.google.common.cache.Cache$put.call(Unknown Source)

运行依赖报告后,我发现问题是由 Spring Security REST 插件的依赖引起的:( com.google.guava:guava-base:r03) - 具有相同的包名称“com.google .common.base”和 Platform.class 没有这样的方法 systemNanoTime()

|    +--- org.grails.plugins:spring-security-rest:2.0.0.M2
| | +--- com.google.guava:guava-io:r03
| | | +--- com.google.guava:guava-annotations:r03
| | | \--- com.google.guava:guava-base:r03
| | | \--- com.google.guava:guava-annotations:r03

有什么办法可以解决这个问题吗?

最佳答案

第 1 步。请检查更新的依赖项 ( issue may be reported ):

dependencies {
compile 'org.grails.plugins:spring-security-rest:2.0.0.RC1'
compile 'com.google.guava:guava:24.0-jre'
}

您可以检查 spring-security-rest documentationrepo对于 Guava documentationrepo

第 2 步。

compile("org.grails.plugins:spring-security-rest:2.0.0.RC1") {
excludes([group: 'com.google.guava:guava'])
}

步骤 3.build.gradle 中,您可以从 JAR 文件中排除已编译的类:

jar {
exclude "com/google/guava/**/**"
}

或者您可以引用grails documentation

关于grails - spring-security-rest 和 guava 之间的间接 jar 冲突导致 NoSuchMethod 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48062376/

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