spring-boot-dependencies-2.6.1.pom中定义了很多个版本和坐标关系
spring-boot-dependencies
(继承只能用一次)避免多个依赖使用相同的技术时出现版本冲突
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
小心版本冲突
减少依赖配置的目的
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@SpringBootApplication
public class Springboot0101QuickstartApplication {
public static void main(String[] args) {
ConfigurableApplicationContext run = SpringApplication.run(Springboot0101QuickstartApplication.class, args);
BookController bean = run.getBean(BookController.class);
System.out.println("book--==>"+ bean);
User bean1 = run.getBean(User.class);
System.out.println("User--==>"+ bean1);
}
}
jetty
应用面广
,负载了若干较重的组件
更轻量级
,负载性能远不及tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>