0
嗨,我想知道是否有可能在Scala中利用Spring注释缓存。我已经尝试过,但正在接收下面的错误。我从一个依赖于scala包的java包运行应用程序。可能在Scala中使用Spring缓存
No cache could be resolved for 'CacheableOperation[public scala.collection.immutable.List MerchantDataGateway.getAllMerchants()]
我的配置类
@Configuration
@EnableCaching
@ComponentScan(basePackages = "xxx.xxx.xxx.xxx")
public class EnvironmentHelperConfig {
@Bean
public CacheManager getCacheManager() {
final int ttl = 12;
final int maxCacheSize = 1012;
GuavaCacheManager result = new GuavaCacheManager();
result.setCacheBuilder(CacheBuilder
.newBuilder()
.expireAfterWrite(ttl, TimeUnit.HOURS)
.maximumSize(maxCacheSize));
return result;
}
}
我的斯卡拉类
@Component
class MerchantDataGateway {
@Autowired
var fmcsProxy: MerchantResource = null;
@Cacheable
def getAllMerchants(): List[MerchantViewModel] = {
val merchants = getAllMerchantsFromFMCS()
merchants.map(merchant => MerchantViewModel.getLightWeightInstance(merchant))
}
}