spring.factories configuration file and @configuration

spring.factories : The spring.factories file is mainly used to implement Spring’s automatic assembly. By defining the relationship between components and interfaces or abstract classes, these components can be automatically loaded and take effect when the Spring container starts. @configuration:
@Configuration annotation It is used to identify a Java class as a configuration class, which may contain various Spring configuration information, such as @Bean method

@configuration and spring.factories are somewhat similar in function but also have differences.
1.spring.factories file is mainly used to realize the automatic assembly and extension of Spring, while @Configuration annotation is mainly used to define the configuration information of the application, and is usually related to Java Classes are used in combination.
2. In terms of scalability, assuming that module a is referenced by project b, and there are @configuration and spring.factories files in project a, the configuration of spring.factories will take effect automatically, but classes with @configuration do need to use @ComponentScan The specified path will be scanned

Guess you like

Origin blog.csdn.net/qq_56533553/article/details/131364281