@Component public class NettyBootstrap implements ApplicationListener<ContextRefreshedEvent> { @Override public void onApplicationEvent(ContextRefreshedEvent event) { if(event.getApplicationContext().getParent() == null){ try { //说明SpringApplication已经启动完毕 WSServer.getInstance().start(); } catch (Exception e) { e.printStackTrace(); } } } }
原文:https://www.cnblogs.com/xiaowenwen/p/14809568.html