Add ApplicationListener example
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package org.baeldung.startup;
|
||||
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class StartupApplicationListenerExample implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
public static int counter;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user