实现InitializingBean 接口中的方法
package com.qingcheng.service.impl;
import com.qingcheng.service.goods.CategoryService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class Init implements InitializingBean {
@Autowired
private CategoryService categoryService;
public void afterPropertiesSet() throws Exception {
System.out.println("=============缓存预热=============");
categoryService.saveCategoryTreeToRedis();
}
}