【发布时间】:2015-03-25 21:28:56
【问题描述】:
我正在尝试为 Stash 插件使用 sn-p 代码,但编译器不断给我一个似乎无法解决的错误。它正在使用 com.google.common.cache.Cache (Guava)
static final RepositorySettings DEFAULT_SETTINGS = new RepositorySettings(0);
private final PluginSettings pluginSettings;
private final Cache<Integer, RepositorySettings> cache = CacheBuilder.newBuilder().build(
new CacheLoader<Integer, RepositorySettings>()
{
@Override
public RepositorySettings load(@Nonnull Integer repositoryId)
{
@SuppressWarnings("unchecked")
Map<String, String> data = (Map) pluginSettings.get(repositoryId.toString());
return data == null ? DEFAULT_SETTINGS : deserialize(data);
}
});
.build 给我以下错误
The method build(CacheLoader<? super Integer,RepositorySettings>) is ambiguous for the type CacheBuilder<Object,Object>
【问题讨论】:
-
Cache有一个不带参数的build()方法,而LoadingCache有一个build()方法,它采用CacheLoader作为参数。
标签: java caching guava ambiguous