注解
1.@PostConstruct
在该类的构造器执行完成后,执行被@PostConstruct修饰的方法。
1 @Component 2 @Slf4j 3 public class RedissonManager { 4 private Config config = new Config(); 5 private Redisson redisson = null; 6 7 public Redisson getRedisson() { 8 return redisson; 9 } 10 private static String redis1Ip = PropertiesUtil.getProperty("redis1.ip"); 11 private static Integer redis1Port = Integer.parseInt(PropertiesUtil.getProperty("redis1.port")); 12 13 //在构造器执行完成后,执行该方法 14 @PostConstruct 15 private void init(){ 16 try { 17 config.useSingleServer().setAddress(new StringBuilder().append(redis1Ip).append(":").append(redis1Port).toString()); 18 19 redisson = (Redisson) Redisson.create(config); 20 21 log.info("初始化Redisson结束"); 22 } catch (Exception e) { 23 log.error("redisson init error",e); 24 } 25 } 26 }
2.@PathVariable
3.@RequestParam
4.@ResponseBody
5.@Controller
6.@RestController

浙公网安备 33010602011771号