In this example, we will see how to register an ApplicationListener via META-INF/spring.factories. Listener added this way can receive the events even before ApplicationContext is created and loaded.
Example
public class MyApplicationListener implements ApplicationListener<ApplicationEvent> {
@Override
public void onApplicationEvent(ApplicationEvent event) {
System.out.println("event: " + event);
}
}