Tom*_*dan 9 grails guava google-guava-cache grails-3.1 grails3
我用grails 3.1.16
的build.gradle:
dependencies {
compile "com.google.guava:guava:18.0"
compile "org.grails.plugins:spring-security-rest:2.0.0.M2"
}
Run Code Online (Sandbox Code Playgroud)
在运行此代码时:
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)
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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)
Run Code Online (Sandbox Code Playgroud)
在运行依赖项报告之后,我发现问题是由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
Run Code Online (Sandbox Code Playgroud)
任何解决这个问题的想法?
步骤1.请检查更新的依赖项(可能会报告问题):
dependencies {
compile 'org.grails.plugins:spring-security-rest:2.0.0.RC1'
compile 'com.google.guava:guava:24.0-jre'
}
Run Code Online (Sandbox Code Playgroud)
您可以查看spring-security-rest 文档和repo 以及guava 文档和repo
第2步.
compile("org.grails.plugins:spring-security-rest:2.0.0.RC1") {
excludes([group: 'com.google.guava:guava'])
}
Run Code Online (Sandbox Code Playgroud)
第3步.在您build.gradle可以从JAR文件中排除已编译的类:
jar {
exclude "com/google/guava/**/**"
}
Run Code Online (Sandbox Code Playgroud)
或者你可以参考grails文档
你有没有尝试过?
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'
}
}
Run Code Online (Sandbox Code Playgroud)
guava-base这将排除from的传递依赖spring-security-rest。
| 归档时间: |
|
| 查看次数: |
291 次 |
| 最近记录: |