变更监听 Spring 事件.

pull/84/head
chen.ma 3 years ago
parent 13498d43cb
commit 3d7792500a

@ -1,8 +1,8 @@
package cn.hippo4j.starter.event; package cn.hippo4j.starter.event;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -12,7 +12,7 @@ import javax.annotation.Resource;
* @author chen.ma * @author chen.ma
* @date 2021/12/25 20:21 * @date 2021/12/25 20:21
*/ */
public class ApplicationContentPostProcessor implements ApplicationListener<ContextRefreshedEvent> { public class ApplicationContentPostProcessor implements ApplicationListener<ApplicationReadyEvent> {
@Resource @Resource
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@ -20,7 +20,7 @@ public class ApplicationContentPostProcessor implements ApplicationListener<Cont
private boolean executeOnlyOnce = true; private boolean executeOnlyOnce = true;
@Override @Override
public void onApplicationEvent(ContextRefreshedEvent event) { public void onApplicationEvent(ApplicationReadyEvent event) {
synchronized (ApplicationContentPostProcessor.class) { synchronized (ApplicationContentPostProcessor.class) {
if (executeOnlyOnce) { if (executeOnlyOnce) {
applicationContext.publishEvent(new ApplicationCompleteEvent(this)); applicationContext.publishEvent(new ApplicationCompleteEvent(this));

Loading…
Cancel
Save