afterPropertiesSet()
在系统初始化之后,就会自动调用该方法,见名知意。
可在这个方法中设置对应的属性值,例如缓存用户数据之类的不需要实时的数据。有例如商城秒杀产品的数据(项目重新部署的时候)
eg:
public void afterPropertiesSet() throws Exception {
List goodsList = iSeckillGoodsService.getSeckillGoodsList();
if (goodsList == null) {
return;
}
for (SeckillGoodVo goods : goodsList) {
redisService.set(Key,Value,timeout);
//可在此处添加程序缓存,减少redis的访问
localOverMap.put(goods.getId(), false);//后面秒杀进行的时候先判断该商品是否已经过时
}
}