Sitemap

Member-only story

Can You Build a Non-Web Application with Spring Boot?

Yes! Spring Boot isn’t just for web apps. Learn how to create non-web (console-based) applications using CommandLineRunner, ApplicationRunner, and disable the web server in Spring Boot.

3 min readMar 25, 2025

--

When most developers think of Spring Boot, they think of REST APIs, web applications, or microservices. But did you know you can use Spring Boot to build non-web, console-based applications too?

Yes, Spring Boot supports non-web applications out of the box, and it’s a great fit for:

  • Command-line tools
  • Batch processors
  • Scheduled jobs
  • Message consumers
  • File or database utilities

Let’s walk through how it works 👇

🧠 What is a Non-Web Application?

A non-web application doesn’t use a servlet container like Tomcat or Jetty. It:

  • Does not expose HTTP endpoints
  • Runs in the console or background
  • Executes business logic and exits (or runs as a daemon)

You get all the Spring Boot benefits — auto-configuration, dependency injection, external configs — but without the web layer.

🚀 Step-by-Step: Building a Non-Web Spring Boot Application

🔹 Step 1: Create a Spring Boot Project

Generate a new Spring Boot project using Spring Initializr:

  • Choose the latest Spring Boot version
  • Add only: spring-boot-starter
    (❌ Don't include spring-boot-starter-web)

🔹 Step 2: Use CommandLineRunner or ApplicationRunner

Spring Boot provides two interfaces for running code at startup:

✅ Example using CommandLineRunner:

@SpringBootApplication
public class NonWebApp implements CommandLineRunner {

public static void main(String[] args) {
SpringApplication.run(NonWebApp.class, args);
}

@Override
public void run(String... args) {
System.out.println("🎯 Running non-web application logic...");
for…

--

--

Responses (1)