Spring boot 大大简化了Spring,用Spring MVC之前的架构,用了Spring Boot那真的是不可同日而语,一个词 :简单,主要是依靠Spring Boot的起步依赖和自动装配两个狠心的原理。
起步依赖spring boot之所以能大大简化了开发的难度,很大一部分便是起步依赖。起步边将所有需要的依赖加入。
本质就是Maven的对象模型–依赖传递。使用 spring-boot-starter-* 开头。
org.springframework.boot spring-boot-starter-web
点进去之后,会发现在引入了很多包。这样包之间也不会有版本冲突便于版本控制。
自动装配org.springframework.boot spring-boot-starter-validation 2.4.5 org.springframework.boot spring-boot-starter-web 2.4.5 org.springframework.boot spring-boot-starter-webflux 2.4.5 org.springframework.boot spring-boot-starter-websocket 2.4.5 org.springframework.boot spring-boot-starter-web-services 2.4.5
Spring Boot还有一个特性就是自动装配,减少了很多不必要的配置,方便一些参数的配置。xml文件配置几乎没有。
使用application、bootstrap的properties以及yml就可以配置自己的参数。
启动类的 @SpringBootApplication 中 @EnableAutoConfiguration属性会将在配置文件中配置的属性配置在启动的参数中。
配置文件的属性会转化在实体类中。比如server.port配置的属性最终会转化在ServerProperties这个类中。
server.port=8088
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
public class ServerProperties {
private Integer port;



