spring启动后初始化某个方法
作者:互联网
有时候我们想要在spring启动后就做一些初始化配置,或者启动一个常住线程,这个时候需要定义一个类,且实现ApplicationRunner接口
@Component public class ZKMasterClient implements ApplicationRunner{ private final Logger logger = LoggerFactory.getLogger(ZKMasterClient.class); @Autowired private CuratorFramework zkClient; @Override public void run(ApplicationArguments args) throws Exception{ System.out.println("**************i'm ZKMasterClient.run()***************"); } }
标签:初始化,spring,private,public,ZKMasterClient,某个,ApplicationRunner,class 来源: https://www.cnblogs.com/wangbin2188/p/14745773.html