https://blog.csdn.net/ilovejava_2010/article/details/7953419
1.自定义类继承ApplicationEvent,给自定义事件加上相应的操作,
2.然后ApplicationContext对象观察到事件后,context.publishEvent(event);传递给实现该事件的监听器类,implements ApplicationListener .
二次调用问题
https://blog.csdn.net/wo541075754/article/details/71720984/
https://blog.csdn.net/wangyang1354/article/details/50759778 重复调用问题
if(contextRefreshedEvent.getApplicationContext().getParent() != null){
return;
}
- if(event instanceof MessageEvent){
-
MessageEvent messageEvent = (MessageEvent) event;
-
System.out.println("信息内容是:" + messageEvent.getMessageContent());
-
}