wuyouzhuguli / SpringAll

循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc
MIT License
28.23k stars 8.12k forks source link

开启运行监听器 #21

Closed yanglin1501804006 closed 4 years ago

yanglin1501804006 commented 5 years ago

你好: 我在文章 https://mrbird.cc/deepin-springboot-application.html 3.2 开启运行监听器 一节中,发现:

你 自定义一个SpringApplicationRunListener接口实现类HelloSpringApplicationRunListener并且在spring.factories文件里配置:

Run Listeners

org.springframework.boot.SpringApplicationRunListener=\ com.example.demo.run.HelloApplicationRunListener

这段运行监听器,我想知道的是 org.springframework.boot.SpringApplicationRunListener 这个key 在 spring-boot-autoconfigure这个jar中spring.factories文件并没有看到, 所以嘛,我想请教一下 这个key 【org.springframework.boot.SpringApplicationRunListener 】来自哪里,请指正一下,thanks !

yanglin1501804006 commented 5 years ago

我的理解是 这样的,org.springframework.boot.SpringApplicationRunListener 是接口 ,就是在spring.factories 配置之后,会加载SpringApplicationRunListener 的实现类,那么 假若有 这么一个接口interfaceA ,该接口是spring或者spring-boot中定义的接口,都可以在spring.factories 中配置interfaceA=value[接口interfaceA的实现类] 这种方式在springboot运行时候的装载吗?

wuyouzhuguli commented 4 years ago

是的