1InitializingBean初始化变量
@Service
public class AirService implements InitializingBean {
public static final Logger logger = LoggerFactory.getLogger(AirService.class);
public static List<Integer> toBeUsedList2 = new ArrayList<>();
@Override
public void afterPropertiesSet() throws Exception {
logger.info("afterPropertiesSet...");
toBeUsedList2.add(1);
toBeUsedList2.add(2);
toBeUsedList2.add(3);
}
@Scheduled(cron = "0/2 * * * * ?")
public void f1() {
logger.info(toBeUsedList2.toString());
}
}
INFO: 2019-01-16 10:07:27 [com.weather.weatherexpert.service.AirService:55] afterPropertiesSet...
INFO: 2019-01-16 10:07:30 [org.springframework.boot.web.embedded.tomcat.TomcatWebServer:206] Tomcat started on port(s): 8080 (http) with context path ''
INFO: 2019-01-16 10:07:30 [com.weather.weatherexpert.WeatherExpe