Spring知识点回顾(07)事件发布和监听

Spring知识点回顾(07)事件发布和监听

1、DemoEvent extends ApplicationEvent {

             public DemoEvent(Object source, String msg){

                    super(source);

                    this.msg = msg;

             }

     }

2、DemoListener implements ApplicationEventListener<DemoEvent> {

            public void onApplicationEvent(DemoEvent event){

            }

     }

3、DemoPublisher {

         public void publish(){

              applicationContext.publishEvent( new DemoEvent(this, msg) );

         }

     }

原文地址:https://www.cnblogs.com/lexiaofei/p/7559646.html