An embedded server lets your Spring Boot app run as a simple program without needing a separate web server setup.
Embedded server concept in Spring Boot
spring-boot-starter-web dependency includes an embedded server like Tomcat by default. @SpringBootApplication public class MyApp { public static void main(String[] args) { SpringApplication.run(MyApp.class, args); } }
The embedded server is included automatically with the web starter dependency.
You don't need to install or configure a separate server like Tomcat or Jetty.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}@SpringBootApplication public class MyApp { public static void main(String[] args) { SpringApplication.run(MyApp.class, args); } }
application.properties.server.port=8081This Spring Boot app runs with an embedded Tomcat server. When you run it, it starts the server automatically. Visiting http://localhost:8080/ shows the message.
package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } @RestController class HelloController { @GetMapping("/") public String hello() { return "Hello from embedded server!"; } }
You can switch embedded servers (Tomcat, Jetty, Undertow) by changing dependencies.
Embedded servers make deployment easier but may use more memory than lightweight servers.
Use application.properties to customize server settings like port or context path.
Embedded servers let Spring Boot apps run standalone without external server setup.
They simplify development and deployment by bundling the server inside the app.
You control the embedded server via dependencies and configuration files.