Can we disable the default web server in a Spring Boot application?

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.

Key Points

Why Disable the Web Server?

Not every Spring Boot application exposes REST APIs or web pages.

Examples

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=none

This prevents Spring Boot from starting any embedded web server.

Method 2: Using application.yml

spring

main

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.

Example

Suppose a company develops a nightly data processing application.

Responsibilities

No REST APIs are needed.

Configuration

spring.main.web-application-type=none

Result

Benefits

Common Use Cases

Default Behavior

By default

spring-boot-starter-web

starts

When

spring.main.web-application-type=none

is set, Spring Boot skips the web server initialization process entirely.

Common Mistakes

Follow-up Questions

Interview Tip

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?

More Spring Boot - Level I interview questions

All Spring Boot - Level I questions