摘要: Spring Boot中有一种非常解耦的扩展机制:Spring Factories。这种扩展机制实际上是仿照Java中的SPI扩展机制来实现的。 什么是 SPI机制 SPI的全名为Service Provider Interface.大多数开发人员可能不熟悉,因为这个是针对厂商或者插件的。在java 阅读全文
posted @ 2021-06-23 13:45 风云快客 阅读(215) 评论(0) 推荐(0) 编辑
摘要: AnnotationConfigServletWebServerApplicationContext 是spring boot在servelet下的默认context, 1: 在父类基于上,可以通过传入指定的包路径。可以通过构造函数,也可以通过scan 2: 还可以通过register来注策Bean 阅读全文
posted @ 2021-06-23 13:15 风云快客 阅读(697) 评论(0) 推荐(0) 编辑
摘要: 实用@Bean和@Import的示例 @Configuration@Import({Dog.class, Cat.class})public class DemoConfig { @Bean("tom") public Person getPerson3(){ System.out.println( 阅读全文
posted @ 2021-06-23 09:39 风云快客 阅读(780) 评论(0) 推荐(0) 编辑
摘要: 声明Bean的注解有: @Component,没有明确的角色 @Service 在业务逻辑层使用, 基本质使用的@Component注解 @Repository 在数据访问层(dao层)使用 @Controller 在展现层使用 @RestController 注入Bean的注解,一般情况下通用: 阅读全文
posted @ 2021-06-23 09:18 风云快客 阅读(29) 评论(0) 推荐(0) 编辑