Why use spring.factories for Spring Boot auto-configuration instead of annotations?

后端 未结 3 1759
感情败类
感情败类 2020-12-29 07:29

The documentation states:

Developing auto-configuration and using conditions

If you work in a company that develops shared libraries, or i

3条回答
  •  天命终不由人
    2020-12-29 07:54

    Because we are not going to scan the world to figure out what auto-configuration classes exist in your project. For one, an auto-configuration is just a regular @Configuration class.

    The way a Spring component is found is via explicit declaration or component scan but we need to know the list of auto-configuration classes way before we actually start the context.

提交回复
热议问题