springboot
两大核心技术起步依赖和自动配置
起步依赖
理解:起步依赖是指spring将提供相关服务的依赖通过传递依赖等方式合成一个传递依赖。
1.spring-boot-starter-xxx就是SpringBoot的起步依赖
如:spring-boot-starter-web里包含springweb,springmvc,spring-boot-starter-tomcat等等与web相关的依赖
2.@SpringBootConfiguration
让启动类可以像@Configuration注解的类一样使用@bean创建bean
自动配置
概念:自动根据配置文件决定是否使用默认配置信息,比如端口号8080
过程:
核心是@EnableAutoConfiguration注解,由启动类的@SpringBootApplication注解继承使用。
-
@EnableAutoConfiguration里的@Import(AutoConfigurationImportSelector.class)导入并调用AutoConfigurationImportSelector的接口方法String[] selectImports()获取目标类的全限定类目。
-
selectImports()里通过getCandidateConfigurations()方法的loadSpringFactories方法获取META-INF/spring.factories文件获取所有全限定类名
(全是自动配置类如:AopAutoConfiguration)
-
然后由spring根据这些全限定类名去加载这些类,加载时根据类的注解如:@ConditionalOnProperty根据是否有相应的配置信息来判断是否加载该配置类
@ConditionalOnClass根据是否有相应的类来判断是否加载该配置类
核心标签作用
spring-boot-starter-parent:封装了java版本,打包插件,springboot相关依赖的版本等等。
MQ消息中间件
其他
分页查询;本质是一条select count(1)查询总页数,一条自动添加limit查询当前页面。