[英]SpringApplicationRunListeners v.s. ApplicationListener
I'm reading the source code of SpringApplication
, and I found two kinds of Listener
. 我正在阅读SpringApplication
的源代码,发现了两种Listener
。
There is a list of ApplicationListner
as class field declared with 有一个ApplicationListner
列表,作为用声明的类字段
private List<ApplicationListener<?>> listeners
And in run
method, I found a SpringApplicationRunListeners
declared with 在run
方法中,我发现一个SpringApplicationRunListeners
声明为
SpringApplicationRunListeners listeners = getRunListeners(args);
What's the difference between them? 它们之间有什么区别?
Thank you very much. 非常感谢你。
ApplicationListner
- Interface to be implemented by application event listeners. ApplicationListner
由应用程序事件侦听器实现的接口。
This might be helpful for better understanding of what is event is spring app https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2 这可能有助于更好地了解什么是春季应用程序事件https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2
SpringApplicationRunListener
- Listener for the SpringApplication
run
method. SpringApplicationRunListener
- SpringApplication
run
方法的侦听器。 A new SpringApplicationRunListener instance will be created for each run. 每次运行都会创建一个新的SpringApplicationRunListener实例。
Spring Boot app launches from a Java main method where you usually do something like SpringApplication.run(...)
. Spring Boot应用程序从Java main方法启动,您通常在其中执行SpringApplication.run(...)
。 Basically, you can use that interface to handle Spring Boot App bootstrap process events. 基本上,您可以使用该接口来处理Spring Boot App引导过程事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.