meine EventListener
Annotation erhalten kein Spring Event. Hier ist mein Code:SpringBoot EventListener empfangen keine Ereignisse
@Component
public class ProxyConfig {
public ProxyConfig() {
System.out.println("I can see this in the console");
}
@EventListener
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
System.out.println("WON'T WORK :-("); // FIXME
}
@EventListener
public void test(ApplicationStartedEvent event) {
System.out.println("WON'T WORK :-("); // FIXME
}
}
Und hier ist meine Application
Klasse:
@SpringBootApplication
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(MyApp.class, args);
}
}
Nach https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2 und https://solidsoft.wordpress.com/2015/09/29/annotation-driven-event-listeners-in-spring-4-2/ es muss funktionieren, aber es immer noch nicht drucken meine „Arbeit nicht :-("String :(
Jede Idee?
Dank!
In welchen Paketen befinden sich 'Application' und' ProxyConfig'? –
'Anwendung' ist im Paket' com.mycompany.app'. Und "ProxyConfig" befindet sich in einem Unterpaket: 'com.mycompany.app.configuration.impl' – user6479676
Durch Erstellen einer 'META-INF/spring.factories'-Datei (siehe http://docs.spring.io/spring-boot/ docs/current/referenz/html/boot-features-feder-application.html # boot-features-application-events-and-listeners es funktioniert ohne die Annotationen, aber nicht mit ... :( – user6479676