美文网首页
spring.factories 文件干啥用的?

spring.factories 文件干啥用的?

作者: 逐影随行 | 来源:发表于2022-02-24 16:26 被阅读0次

通常来说在springboot应用中扫描bean是在一个固定的目录下,当我们存在一个类不在这个特定的目录下的时候我们要怎么做呢?

只需要在这个文件中配置好我们的类就可以了
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
com.test.Test

这也经常用在springboot starter的编写中

新增一个配置类DemoConfig
在配置文件中添加如下配置
1 #-------starter自动装配---------
2 org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.demo.starter.config.DemoConfig

相关文章

网友评论

      本文标题:spring.factories 文件干啥用的?

      本文链接:https://www.haomeiwen.com/subject/pwnzlrtx.html