Yes, Spring Boot allows us to disable the embedded web server and run the application as a non-web application. This is useful for applications that perform background processing, batch jobs, message consumption, scheduling tasks, or command-line operations where HTTP endpoints are not required.
Why Disable the Web Server?
Not every Spring Boot application exposes REST APIs or web pages.
In these cases, starting an embedded web server is unnecessary.
How to Disable the Web Server?
Method 1: Using application.properties
application.properties
spring.main.web-application-type=noneThis prevents Spring Boot from starting any embedded web server.
Method 2: Using application.yml
web-application-type: none
This achieves the same result using YAML configuration.
Method 3: Programmatically
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
public class Application {
public static void main(String[] args) {
new SpringApplicationBuilder(Application.class)
.web(WebApplicationType.NONE)
.run(args);
}
}This explicitly tells Spring Boot to run as a non-web application.
What Happens Internally?
Application Starts
|
Spring Context Created
|
Beans Initialized
|
No Embedded Server Started
|
Application Ready
The Spring container starts normally, but Tomcat, Jetty, or Undertow is not launched.
Suppose a company develops a nightly data processing application.
No REST APIs are needed.
spring.main.web-application-type=none
Benefits
Common Use Cases
Default Behavior
spring-boot-starter-web
spring.main.web-application-type=none
is set, Spring Boot skips the web server initialization process entirely.
A concise interview answer is
Yes, we can disable the embedded web server in Spring Boot by setting spring.main.web-application-type=none in application.properties or application.yml. This converts the application into a non-web application, which is useful for batch processing, scheduled jobs, messaging applications, and other background services where HTTP endpoints are not required.
Last updated: 11 November 2026
Previous question: What is the default port of Tomcat in Spring Boot?
Next question: How do you disable a specific auto-configuration class in Spring Boot?