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))
}
}