WAR deployment and Embedded Container deployment are two different approaches for running Java web applications. In the traditional approach, the application is packaged as a WAR file and deployed to an external application server. In contrast, Spring Boot packages both the application and the web server together, allowing the application to run as a standalone executable JAR.
Key Points: • WAR deployment requires a separate application server such as Tomcat or WildFly. • Embedded containers package the server and application together. • Spring Boot commonly uses embedded Tomcat by default. • Embedded containers simplify deployment and environment management. • Modern microservices architectures generally prefer embedded containers.
What is WAR Deployment?
WAR stands for:
Web Application Archive
A WAR file contains:
• Application code • JSP files • Configuration files • Libraries
The WAR file must be deployed to an external server.
Example:
employee-app.war
Deployment Process:
Application | WAR File | External Tomcat | Application Runs
Common Servers:
• Apache Tomcat • Jetty • WildFly • WebLogic • WebSphere
What is an Embedded Container?
An embedded container is a web server packaged inside the application itself.
Examples:
• Embedded Tomcat • Embedded Jetty • Embedded Undertow
Spring Boot packages everything into a single executable JAR.
Example:
employee-app.jar
Execution:
java -jar employee-app.jar
The server starts automatically along with the application.
Deployment Process:
Application | Embedded Tomcat | Executable JAR | Application Runs
Comparison
1. Packaging
WAR Deployment
• Generates a .war file
Example:
employee-app.war
Embedded Container
• Generates an executable .jar file
Example:
employee-app.jar
2. Server Requirement
WAR Deployment
• Requires external server installation
Examples:
• Tomcat • WildFly
Embedded Container
• No external server required
The server is bundled with the application.
3. Deployment Process
WAR Deployment
1. Build WAR 2. Install server 3. Deploy WAR 4. Start server
Embedded Container
1. Build JAR 2. Run JAR
Much simpler deployment.
4. Configuration Management
WAR Deployment
• Server configuration may differ across environments
Potential issues:
• Development works • Production behaves differently
Embedded Container
• Same server version everywhere
Benefits:
• Consistent environments • Fewer deployment issues
5. Microservices Support
WAR Deployment
• Less commonly used in modern microservices
Embedded Container
• Ideal for microservices and cloud-native applications
Works well with:
• Docker • Kubernetes • Spring Cloud
Example:
Traditional Enterprise Application
employee-app.war
↓
External Tomcat
↓
Application Runs
Spring Boot Application
employee-app.jar
↓
Embedded Tomcat
↓
java -jar employee-app.jar
↓
Application Runs
Advantages of WAR Deployment
• Useful in legacy enterprise environments • Centralized server management • Multiple applications can share one server
Advantages of Embedded Containers
• Faster deployment • Easier configuration • Better portability • Consistent runtime environment • Excellent support for cloud deployment
Real-World Example
Legacy Banking System
Deployment:
banking-app.war
↓
Enterprise Tomcat Cluster
Modern Microservice
Deployment:
payment-service.jar
↓
Docker Container
↓
Kubernetes
The embedded container approach is now the preferred choice for most Spring Boot applications because it simplifies deployment and scales well in cloud environments.
Interview Tip: A concise interview answer is:
"In traditional deployment, a Java application is packaged as a WAR file and deployed to an external server such as Tomcat or WildFly. With Spring Boot, an embedded container like Tomcat is packaged inside the application, creating a standalone executable JAR. This simplifies deployment, ensures consistent environments, and is the preferred approach for modern microservices and cloud-native applications."