Why use spring.factories for Spring to automatically configure downloads instead of annotations?

The documentation states:

Development of automatic configuration and conditions of use

If you work in a company that develops shared libraries, or if you work in an open or commercial library, you can develop your own autoconfiguration. Autoconfiguration classes can be merged into external banks and still boot using Spring Boot.

If I have annotations for everything else (even @AutoConfigureAfter or @AutoConfigureBefore annotations),

Why save a properties file to indicate a class with annotation?

+5
source share
1 answer

Because we are not going to scan the world to find out what autoconfiguration classes exist in your project. For example, autoconfiguration is the usual @Configuration class.

The way to discover a Spring component is through explicitly declaring or checking the components, but we need to know the list of automatic configuration classes before we start the context.

+10
source

All Articles