Java org.springframework.boot.spring-boot POM的用途是什么?
Sprint BootJava org.springframework.boot.spring-boot POM的用途是什么?,java,spring,spring-boot,maven,Java,Spring,Spring Boot,Maven,Sprint Bootorg.springframework.Boot.springboot 它包括 org.springframework.spring-core org.springframework.spring-context 所以像你这样的人 为什么不直接创建org.springframework.boot.springbootstarterweb org.springframework.spring-webmvc org.springframework.spring-core or
org.springframework.Boot.springboot
它包括
org.springframework.spring-core
org.springframework.spring-context
所以像你这样的人
为什么不直接创建org.springframework.boot.springbootstarterweb
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
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
中定义的所有类和注释(springboot
依赖于springcore
和springcontext
,但它本身实现了一些重要的类,见下文)
以spring boot starter web
为例,通常我们需要在应用程序.yml
中设置server.port
,该属性在spring boot autoconfigure
项目的类中定义(这就是为什么我们需要spring boot starter
中的原因),还有其他常用属性,如server.address
,server.servlet.context path
,和server.ssl.*
…等等。它们都在spring boot autoconfigure
项目中定义
为了自动配置中定义的属性,将创建类作为参数,并应用其值来设置软件,如
现在请注意,它既没有使用@Configuration
注释,也没有使用@Component
注释,因此在进行组件扫描时它不会被实例化,因此创建此注释是为了确保的实例将被注入。此注释在spring boot
项目中定义,这就是我们需要spring boot
de的原因悬而未决。它被使用了
关于什么是spring boot starter以及它是如何工作的,这里有一篇有用的文章:这就是我试图理解的-你遗漏了什么“重要的依赖项”?我在这里没有看到任何其他内容
jakarta.annotation-api
spring-core
spring-boot
spring-boot-autoconfigure
spring-boot-starter-logging