参考链接:https://www.jianshu.com/p/c2e33c451ee0
在项目中,我们会使用到自定义bean,做一些特定义的功能方法,示例如下所示:
@Service
public class ProductService implements InitializingBean, DisposableBean {
@Autowired
private ProductSvcRemoteService productRemoteService;
// 创建本地缓存1:缓存产品信息
private Cache<String, ProductInfoGson> localeProductInfoCache;
// 创建本地缓存2:缓存产品id
private Cache<String, Long> productCodeToIdCache;
private static final String SEPARATOR = “|”;
// 程序
spring InitializingBean与DisposableBean的使用
最新推荐文章于 2020-12-21 21:49:29 发布
本文介绍了如何在Spring中使用InitializingBean和DisposableBean接口进行自定义Bean的初始化和销毁操作。示例展示了如何在afterPropertiesSet方法中初始化本地缓存,并在destroy方法中清理缓存。
摘要由CSDN通过智能技术生成