06 2021 档案
摘要:1: FilterRegistrationBean 是核心是 ServletContextInitializer的一个实现,可以改变servletContext上下文,这里的作用是在serveltContext中加入Filter 是spring Boot 来组织的这些初始化。 2: SpringSe
阅读全文
摘要:Spring Boot中有一种非常解耦的扩展机制:Spring Factories。这种扩展机制实际上是仿照Java中的SPI扩展机制来实现的。 什么是 SPI机制 SPI的全名为Service Provider Interface.大多数开发人员可能不熟悉,因为这个是针对厂商或者插件的。在java
阅读全文
摘要:AnnotationConfigServletWebServerApplicationContext 是spring boot在servelet下的默认context, 1: 在父类基于上,可以通过传入指定的包路径。可以通过构造函数,也可以通过scan 2: 还可以通过register来注策Bean
阅读全文
摘要:实用@Bean和@Import的示例 @Configuration@Import({Dog.class, Cat.class})public class DemoConfig { @Bean("tom") public Person getPerson3(){ System.out.println(
阅读全文
摘要:声明Bean的注解有: @Component,没有明确的角色 @Service 在业务逻辑层使用, 基本质使用的@Component注解 @Repository 在数据访问层(dao层)使用 @Controller 在展现层使用 @RestController 注入Bean的注解,一般情况下通用:
阅读全文