首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring-security-rest和芭乐之间的间接jar冲突导致NoSuchMethod错误

spring-security-rest和芭乐之间的间接jar冲突导致NoSuchMethod错误
EN

Stack Overflow用户
提问于 2018-01-02 22:02:36
回答 2查看 390关注 0票数 10

我使用grails 3.1.16

build.gradle:

代码语言:javascript
复制
dependencies {
    compile "com.google.guava:guava:18.0"
    compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
}

在运行此代码时:

代码语言:javascript
复制
   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)
    }

我收到以下错误:

代码语言:javascript
复制
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“和没有这种方法systemNanoTime()的Platform.class。

代码语言:javascript
复制
|    +--- 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

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

EN

回答 2

Stack Overflow用户

发布于 2018-03-06 04:26:44

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

代码语言:javascript
复制
dependencies {
    compile 'org.grails.plugins:spring-security-rest:2.0.0.RC1'
    compile 'com.google.guava:guava:24.0-jre'
}

您可以检查spring-security-rest documentationrepo,以及芭乐documentationrepo

步骤2.

代码语言:javascript
复制
compile("org.grails.plugins:spring-security-rest:2.0.0.RC1") {
            excludes([group: 'com.google.guava:guava'])
}

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

代码语言:javascript
复制
jar {
 exclude "com/google/guava/**/**"
}

或者您可以参考grails documentation

票数 8
EN

Stack Overflow用户

发布于 2018-03-02 08:21:03

你试过了吗?

代码语言:javascript
复制
dependencies {
    compile "com.google.guava:guava:18.0"
    compile ("org.grails.plugins:spring-security-rest:2.0.0.M2") {
        exclude module: 'guava-base'

        // can also be specified with group
        // exclude group: 'com.google.guava', module: 'guava-base'
    }
}

这将从spring-security-rest中排除guava-base的传递依赖项。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48062376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档