Video in progress
What is an embedded server in Spring Boot, and why don't we install Tomcat separately?
An embedded server is Tomcat (or Jetty, Undertow) packaged into the application as a library. When you run java -jar, the server starts along with it.
📖 Answer
In the old days a Java web application was built as a .war and dropped into a separately installed Tomcat. The server version and its settings lived apart from the application and differed from one environment to another.
In Spring Boot, spring-boot-starter-web brings Tomcat in as a dependency. When main runs, Boot creates Tomcat from code and opens the port.
What you gain:
- every application ships with its own server version — fewer "works on my machine" problems;
- in a Docker container, a JRE and one jar are enough;
- server settings live in the application config:
server.port,server.tomcat.threads.maxand so on.
To switch to another server, you exclude Tomcat and add spring-boot-starter-jetty. You can still build a .war and deploy it to an external server, but in new projects that's rare.
Sign up to mark studied questions and save your progress.