程序启动时加载-@PostConstruct

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static Map<String, String>commandMap= null;

// 项目启动时加载该方法
@PostConstruct
private void start() {
if (commandMap!= null) {
return;
}
List<DeviceCommand> deviceCmds = sqlManager.lambdaQuery(DeviceCommand.class).select("name", "command");
commandMap= new HashMap<>();
for (DeviceCommand deviceCmd : deviceCmds) {
DeviceCommandLogService.commandMap.put(deviceCmd.getCommand(), deviceCmd.getName());
}
}

程序结束时加载-@PostConstruct
。。。