Spring Boot 工程作为 SDK 依赖库方式自动注入 Bean 类
Spring Boot About 979 words需求
抽取公共模块,以SDK的方式被宿主引入。在这个SDK中,自动注入@Configuration、@Bean、@Component、@Service、@Repository、@Controller等在SDK工程中定义的Bean类。
Bean 类
所有Bean类都位于com.example.service。
自动配置类
@ComponentScan(basePackages = {"com.example.service"})
@AutoConfiguration
public class MyAutoConfiguration {
}
Spring Boot 2.7 及 3
└── resources
├── META-INF
│ └── spring
│ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports
在org.springframework.boot.autoconfigure.AutoConfiguration.imports文件中添加com.example.MyAutoConfiguration全路径类名。
com.example.app.MyConfiguration
com.example.app.MyConfiguration2
Spring Boot 2.7 以下
└── resources
├── META-INF
│ └── spring.factories
spring.factories文件内容
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.example.app.MyConfiguration, \
com.example.app.MyConfiguration2
参考链接
Views: 1,279 · Posted: 2024-03-28
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...