我使用 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
有什么想法可以解决这个问题吗?