这个POM在Sprint Boot org.springframework.boot.spring-boot中的目的是什么?
它包括
org.springframework.spring-core
org.springframework.spring-context所以在像org.springframework.boot.spring-boot-starter-web这样的东西里
org.springframework.spring-webmvc
org.springframework.boot.spring-boot-starter
org.springframework.boot.spring-boot-starter-json
org.springframework.boot.spring-boot-starter-tomcat为什么不直接让org.springframework.boot.spring-boot-starter-web
org.springframework.spring-webmvc
org.springframework.spring-core
org.springframework.spring-context
org.springframework.boot.spring-boot-starter-json
org.springframework.boot.spring-boot-starter-tomcat发布于 2020-09-03 02:57:19
spring-boot-starter有以下依赖关系:
jakarta.annotation-api
spring-core
spring-boot
spring-boot-autoconfigure
spring-boot-starter-logging如果您将spring-boot-starter替换为spring-core和spring-context,那么您将忽略spring-boot和spring-boot-autoconfigure中定义的所有类和注释(spring-boot依赖于spring-core和spring-context,但它已经实现了一些重要的类本身,参见下面)。
以spring-boot-starter-web为例,通常我们需要在application.yml中设置server.port,这个属性是在spring-boot-autoconfigure项目中的ServerProperties类中定义的(这就是为什么我们在org.springframework.boot.spring-boot-starter-web中需要spring-boot-starter ),还有其他常用的属性,比如server.address、server.servlet.context-path和server.ssl.* ....etc.They都是在spring-boot-autoconfigure项目中定义的。
为了自动配置ServerProperties中定义的属性,创建了类ServletWebServerFactoryAutoConfiguration,以ServerProperties作为参数,并应用它的值来设置像猫猫这样的软件
现在请注意,ServerProperties既不是用@Configuration注释的,也不是用@Component注释的,所以在组件扫描发生时不会实例化它,所以创建这个注释EnableConfigurationProperties是为了确保ServerProperties的实例被注入。这个注释是在spring boot项目中定义的,这就是为什么我们需要spring-boot依赖。而且它被使用了这里。
关于什么是spring引导启动程序以及它是如何工作的,下面是一篇有用的文章:建立弹簧启动器的快速指南
https://stackoverflow.com/questions/63714674
复制相似问题