Spring boot 事件监听器 Application events and listeners Application

package com.example.demo.entity;

import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

//只要将自定义的时间监听器放入容器内,时间监听器就会自动应用在springboot应用上,不需要显式调用API,springboot版本2.0.2

@Component
public class ApplicationListenerStarted implements ApplicationListener<ApplicationStartedEvent> {
    @Override
    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
        System.out.println("ApplicationStartedEvent!!!!!!!!!!!!!!");
    }
}

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页