spring - 会话范围 CacheManager 不能在 @Cacheable 中使用。如何解决?
问题描述
我有两个带有单例(这个是主要的)和会话范围的缓存管理器。我指出,在 MyRepository 类中,我想通过方法上的以下注释使用“sessionBasedCache”:
@Cacheable(value = "members", key = "#id.value()", cacheManager = "sessionBasedCache")
...
当“sessionBasedCache”被调用时,我得到了这个异常:
setAttribute: Non-serializable attribute with name scopedTarget.epeSessionBasedCache
这是我的配置:
@Bean(name = "sessionBasedCache")
@Scope(value = "session", proxyMode = ScopedProxyMode.INTERFACES)
public CacheManager epeSessionBasedCacheManager() {
return new GuavaCacheManager();
}
我已经尝试过:如果我在单例范围内使用缓存,一切都很好。我查看了 SimpleCacheManager,它是默认的弹簧缓存。而且它没有实现可序列化。
您对发生的事情以及如何解决它有任何想法吗?
解决方案
推荐阅读
- flutter - 《如何在 Flutter 中使用 Facebook 应用事件》
- html - 更改响应图像的水平中心和宽度
- python-3.x - 如何根据最大值进行注释并乘以最大值的 2 和 3
- html - 使用 bing.com 引擎(电机)研究的标题页上的请求:html
- python - 我的 json 搜索 python 中的冲突 id() 函数
- asp.net-core - 如何手动分配用户
- flutter - Adobe XD 抖动代码导致“RenderCustomMultiChildLayoutBox 对象在布局期间被赋予无限大小”。错误
- .net-5 - 引用的程序集是使用较新版本的 Microsoft.Windows.SDK.NET.dll 编译的
- python - pyrevit 脚本键盘快捷键
- r - 当我尝试在 r 中列出向量时,为什么会出现错误?