Card 04/ 06
All 6 cards
GotchaDifficulty: Advanced1 min
Swapping the Embedded Server
Adding spring-boot-starter-jetty to a project that already has spring-boot-starter-web does not switch anything — both server libraries end up on the classpath, and Boot has to guess which one you meant.
<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>Server: JettyWebServerspring-boot-starter-tomcat has to be excluded from spring-boot-starter-web explicitly, because the starter that brings in MVC also decides which server ships with it. Exclude the one you don't want, add the one you do, and auto-configuration picks up the only embedded-server implementation left on the classpath — no other code changes.