Close

Spring Boot - Customizing application startup

[Last Updated: Nov 6, 2026]

When we start a Spring Boot application with the static method SpringApplication.run(), Spring Boot uses its default settings. In this tutorial, we will see how to change some of these defaults. We will move quickly, with short examples.

These examples use the spring-boot-starter dependency (the core Spring context only, no web server). Instead of calling the static run() method, we create a SpringApplication object. This lets us change its settings before we call run(). We do not use @SpringBootApplication on the main class, because we are not defining any beans here:

package com.logicbig.example;

import org.springframework.boot.SpringApplication;

public class CustomizeBootExample {
    public static void main (String[] args) {
        SpringApplication app = new SpringApplication(CustomizeBootExample.class);

        //customize here
        app.run(args);
    }
}

In the next sections, we will add our settings in the empty line before app.run(args).

This tutorial shows the current behavior (Spring Boot 4.x, 2026). Where older versions worked differently, we say so in a note. A summary is at the end, in the "Version history" section.



Example

Project setup (Maven and Gradle)

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>4.1.2</version>
  </parent>
  <groupId>com.logicbig.example</groupId>
  <artifactId>boot-startup-customizing</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <java.version>25</java.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>
  </dependencies>
</project>
plugins {
    java
    id("org.springframework.boot") version "4.1.2"
    id("io.spring.dependency-management") version "1.1.7"
}

println(">>> EXECUTING SCRIPT: build.gradle.kts (Kotlin DSL)")

group = "com.logicbig.example"
version = "1.0-SNAPSHOT"

java {
    sourceCompatibility = JavaVersion.VERSION_25
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter")
}
plugins {
    id 'java'
    id 'org.springframework.boot' version '4.1.2'
    id 'io.spring.dependency-management' version '1.1.7'
}

println ">>> EXECUTING SCRIPT: build.gradle (Groovy DSL)"

group = 'com.logicbig.example'
version = '1.0-SNAPSHOT'

java {
    sourceCompatibility = JavaVersion.VERSION_25
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
}

The only dependency we need is spring-boot-starter. With Maven, we add it like this (the version comes from spring-boot-starter-parent):

With Gradle, the org.springframework.boot Gradle plugin and the dependency management plugin supply the version. The complete pom.xml, build.gradle and build.gradle.kts files are in the example project below. The Java code is the same for all build tools.



Turning off startup info logs

By default, Spring Boot logs a few lines about the application itself, for example "Starting ... using Java ... with PID ...", the active profile, and "Started ... in ... seconds". We can turn them off with setLogStartupInfo(false). The same setting is available as the property spring.main.log-startup-info=false.

package com.logicbig.example;

import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;

public class TurnOffLogsExample {
    public static void main(String[] args) throws MalformedURLException {
        SpringApplication app = new SpringApplication(TurnOffLogsExample.class);
        app.setLogStartupInfo(false);
        app.run(args);
    }
}

Output


. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)

Only the banner is printed.


Turning off the banner

We use Banner.Mode to control the banner. It has three values: CONSOLE (the default, prints to System.out), LOG (writes the banner to the log) and OFF. The property for this is spring.main.banner-mode (for example spring.main.banner-mode=off).

package com.logicbig.example;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;

public class BannerOffExample {
    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(BannerOffExample.class);
        app.setBannerMode(Banner.Mode.OFF);
        app.run(args);
        System.out.println("Banner off Example");
    }
}

Output

2026-11-06 05:00:19.619  INFO 37936 --- [           main] com.logicbig.example.BannerOffExample    : Starting BannerOffExample on JoePC with PID 37936 (D:\LogicBig\example-projects\spring-boot\boot-startup-customizing\target\classes started by joe2 in D:\LogicBig\example-projects\spring-boot\boot-startup-customizing)
2026-11-06 05:00:19.629 INFO 37936 --- [ main] com.logicbig.example.BannerOffExample : No active profile set, falling back to default profiles: default
2026-11-06 05:00:19.893 INFO 37936 --- [ main] com.logicbig.example.BannerOffExample : Started BannerOffExample in 0.942 seconds (JVM running for 9.316)
Banner off Example

Using an image for the banner (removed in Spring Boot 3.0)

This feature does not exist in current versions. Image banners worked in Spring Boot 1.x and 2.x (up to 2.7). Spring Boot 3.0 removed the ImageBanner class and the spring.banner.image.* properties. The code below compiles only with Spring Boot 2.7 or older.

In those old versions, Spring Boot converted the image to ASCII art and printed it as the banner:

public static void main (String[] args) throws MalformedURLException {
     SpringApplication app = new SpringApplication(CustomizeBootExample2.class);
     UrlResource r = new UrlResource("https://www.logicbig.com/tutorials/" +
                                               "spring-framework/spring-boot/" +
                                               "images/spring-boot.png");
     app.setBanner(new ImageBanner(r));
     app.run(args);
 }

Output (Spring Boot 1.4.2)

8888888&&&&&&&&&&&&&&&&&ooooooooooooo:::::::::::::::
             8888888&&&&&&&&&&&&&&&&&oooooooooooo::::::::::::::::
             8888888&&&&&&&&&&&&&&&&&&&oo:ooooooo::::::::::::::::
             8888888&88&&&&&&&&&&&&&&    o.     ::::::::::::::::
             8888888888&&&&&&&&&&&&&&8  .8&   *  .:::::::::::::::
             8888888&88&&&&&&&&&&&&&o  88   *o   :::::::::::::::
             8888888&&&&&&&&&&&&&&&&&8       o   ::::::::::::::::
             8888888888&&&&&&&&&&&&&&&8     oo  oo:::::::::::::::
             8888888888&&&&&&&&&&&&&&8           *:::::::::::::::
             8888888888&&&&&&&&&&&&&&&           *:::::::::::::::
             8888888888&&&&&&&&&&&&&&&&&88  :oo  *:::::::::::::::
             8888888888&&&&&&&&&&&&&&&&&88       *:::::::::::::::
             8888888888&&&&&&&&&&&&oo&&&888      ::::::::::::::::
             88888888888&&&&&&&&&&&&&&           *:::::::::::::::
             88888888888&&&&&&&&&&&&&&           *:::::::::::::::
             888888888        &&&&&&&&&888   oo  *:::::::::::::::
             888888888  &  &  &&&&&&&&88     oo  *:::::::::::::::
             888888888  &     &&&&&&&&           ::::::::::::::::
             888888888.   &  &&&&&&&&&  888&:  .:::::::::::::::::
             8888888888&   *&&&&&&&&&&           . :   ::::::::::
             888888888        &&&&&&&&           *   *  :::::::::
             88888888  8&&&&  &&&&&&&&:::::****..:::    *::::::::
             888888888   ..   &&&&&&&&           *::::::**:::::::
             8888888888     &&&&&&&&&&&&888      ::::::::::::::::
             8888888888&   *&&&&&&&&&&88      o::::::::::::::::::
             888888888        &&&&&&&&           *:::::::::::::::
             88888888  8&&&&  &&&&&&&&           *:::::::::::::::
             888888888   ..   &&&&&&&&&888. .ooo:::::::::::::::::
             8888888888     &&&&&&&&&&8         :::::::::::::::::
             88888888888&&&&  &&&&&&&&   *8&o.   ::::::::::::::::
             888888888&&&&&&  &&&&&&&o  &o&&ooo   :::::::::::::::
             888888888        &&&&&&&&  &&  oo    :::::::::::::::
             88888888888&&&&  &&&&&&&&      oo   ::::::::::::::::
             88888888888&&&&&&&&&&&&&o&*....ooo::::::::::::::::::
             8888888888&&&&&&&&&&&&&&oooooooo::::::::::::::::::::
             8888888888&&&&&&&&&&&&&&oooooooo::::::::::::::::::::

2016-12-14 21:26:22.395  INFO 8148 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@b7f23d9: startup date [Wed Dec 14 21:26:22 CST 2016]; root of context hierarchy
2016-12-14 21:26:23.261  INFO 8148 --- [           main] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@b7f23d9: startup date [Wed Dec 14 21:26:22 CST 2016]; root of context hierarchy

In those old versions, we could also put a file named banner.gif, banner.jpg or banner.png in the classpath, or set spring.banner.image.location (in Spring Boot 1.x the property was banner.image.location).

What to do now: convert the image to ASCII art yourself (many free online tools do this) and save the result as banner.txt, or write a custom Banner (see below).


Using banner.txt

By default, Spring Boot looks for a file named banner.txt in the root of the classpath and prints it as the banner. We can use another file with the property spring.banner.location (for example classpath:my-banner.txt or file:/path/to/banner.txt). If the file is not UTF-8, we set its encoding with spring.banner.charset. The file can also contain placeholders such as ${spring-boot.version}. See the Spring Boot reference documentation (link at the bottom) for the full list.

In this example, we put banner.txt in the resources folder. This folder is the same for Maven and Gradle projects:

src/main/resources/banner.txt

---------------------
Test Banner
---------------------
public static void main (String[] args) {
        SpringApplication app = new SpringApplication(CustomizeBootExample3.class);
        app.setLogStartupInfo(false);
        app.run(args);
    }

Output

---------------------
Test Banner
---------------------

Older versions: with the old Spring Framework 4.x, the "Refreshing ..." and "Closing ..." INFO lines were printed after the banner. Also, in Spring Boot 1.x the property names were banner.location and banner.charset (without the spring. prefix).


Using a custom Banner implementation

Banner is a functional interface with one method, printBanner(). So in modern Java we can pass a lambda expression:

package com.logicbig.example;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
import java.io.PrintStream;
import java.net.MalformedURLException;

public class CustomBannerExample {
    public static void main(String[] args) throws MalformedURLException {
        SpringApplication app = new SpringApplication(CustomBannerExample.class);
        app.setLogStartupInfo(false);
        app.setBanner(new Banner() {
            @Override
            public void printBanner(Environment environment,
                                    Class<?> sourceClass,
                                    PrintStream out) {
                out.println("--- my custom banner ---");
            }
        });
        app.run(args);
    }
}

Output

--- my custom banner ---

Important: a Banner set with setBanner() is used only when no banner.txt (or spring.banner.location file) is found. If such a file exists, it is printed instead of our custom banner. (In Spring Boot 2.7 and older, an image banner was also printed in addition to the text banner.)

Also check out SpringBootBanner.java source code to see how Spring Boot implements its own default banner.




A fluent alternative: SpringApplicationBuilder

If we do not want a separate variable, we can use SpringApplicationBuilder. Its methods return the builder, so we can chain them:

public static void main (String[] args) {
     new SpringApplicationBuilder(CustomizeBootExample.class)
             .bannerMode(Banner.Mode.OFF)
             .logStartupInfo(false)
             .run(args);
 }



Using application.properties

We can move startup settings out of the code and into a properties file. By default, Spring Boot reads application.properties (or application.yml / application.yaml) from the classpath. The settings of SpringApplication use the prefix spring.main, and the banner settings use the prefix spring.banner.

src/main/resources/application.properties

spring.main.banner-mode=off
spring.main.log-startup-info=false

The same settings in YAML:

src/main/resources/application.yml

spring:
  main:
    banner-mode: "off"
    log-startup-info: false

In YAML, we must put off in quotes. Without quotes, YAML reads it as the boolean false.

We can use a different file name (instead of application) with this command line argument:

--spring.config.name=my-application

Here is the list of Common application properties.

In this tutorial, we only look at how to apply properties. We will not go through every property. We will look at the other important ones in later tutorials.




Using command line arguments for customization

Instead of a property file, we can also use command line arguments. For example:

--spring.banner.location=my-banner.txt
--spring.main.banner-mode=off

We can pass these arguments when we run the application with a build tool. With Maven: mvn spring-boot:run -Dspring-boot.run.arguments="--spring.main.banner-mode=off". With Gradle (Groovy or Kotlin DSL): ./gradlew bootRun --args="--spring.main.banner-mode=off".

Priority rules: command line arguments override property files. Values from property files and command line arguments also override the values we set in code for the spring.main.* properties. Default properties (see the next section) have the lowest priority of all.

Older versions: in Spring Boot 1.x, the argument was --banner.location=my-banner.txt. The properties without the spring. prefix were removed in Spring Boot 2.0.




Using SpringApplication#setDefaultProperties()

SpringApplication provides two methods for setting default properties in code.

public void setDefaultProperties(Map<String,
                                 Object> defaultProperties)
public void setDefaultProperties(Properties defaultProperties)

Default properties have the lowest priority. Any other source (property file, command line, environment variable) can override them.

Here is an example. First, the banner file:

src/main/resources/my-banner.txt

---------------------
My Banner
---------------------
package com.logicbig.example;

import org.springframework.boot.SpringApplication;
import java.net.MalformedURLException;
import java.util.Properties;

public class SetDefaultPropertiesExample {
    public static void main(String[] args) throws MalformedURLException {
        SpringApplication app = new SpringApplication(CustomBannerExample.class);
        Properties p = new Properties();
        p.setProperty("spring.banner.location", "my-banner.txt");
        p.setProperty("spring.main.log-startup-info", "false");
        app.setDefaultProperties(p);
        app.run(args);
    }
}

Output

---------------------
Test Banner
---------------------

We can set any other property in the same way, for example a log level such as logging.level.org.springframework=DEBUG. We do not show that output here, because it prints a lot of lines.

Older versions: in Spring Boot 1.x the example used the property banner.location and created a Properties object with setProperty() calls. Both overloads of setDefaultProperties() still exist today.




Version history

This is a short summary of how startup customizing changed over the years. The tutorial above describes the current behavior.

  • Spring Boot 1.x (2014 - 2018): banner properties had no spring. prefix (banner.location, banner.charset, banner.image.location). Version names ended with .RELEASE, for example 1.4.2.RELEASE. Spring Framework 4.x logged the "Refreshing ..." and "Closing ..." lines at INFO level.
  • Spring Boot 2.0 (2018): the banner properties were renamed to spring.banner.*, and the old names were removed.
  • Spring Boot 2.4 (2020): the .RELEASE suffix was dropped from version names (2.4.0, 2.4.1, and so on).
  • Spring Boot 3.0 (2022): Java 17 became the minimum. Image banner support was removed. The default log timestamp changed to the ISO-8601 format (for example 2026-11-05T10:15:30.123+08:00).
  • Spring Boot 4.0 (November 2025): based on Spring Framework 7, with Java 17 as the minimum (Java 25 is supported). The startup customizing API in this tutorial did not change.
  • Spring Boot 4.1 (June 2026): the current release line when this tutorial was updated. Please check spring.io for newer releases.

Deprecated or removed features

  • Removed in Spring Boot 3.0: ImageBanner, banner.gif/jpg/png files and the spring.banner.image.* properties.
  • Removed in Spring Boot 2.0: the banner properties without the spring. prefix, such as banner.location.
  • Not deprecated (checked in Spring Boot 4.1): setBanner(), setBannerMode(), setLogStartupInfo(), both setDefaultProperties() methods, and the spring.config.name property.
  • Support: open source support for Spring Boot 3.5 ended on June 30, 2026. Spring Boot 4.0 is supported until December 31, 2026. New projects should use the 4.1 line or newer.

Example Project

Dependencies and Technologies Used:

  • Spring Boot 4.1.2
    Corresponding Spring Framework Version 7.0.10
     Version Compatibility: 2.0.0.RELEASE - 4.1.2Version List
    ×

    Version compatibilities of spring-boot-starter-parent with this example:

    • 2.0.0.RELEASE
    • 2.0.1.RELEASE
    • 2.0.2.RELEASE
    • 2.0.3.RELEASE
    • 2.0.4.RELEASE
    • 2.0.5.RELEASE
    • 2.0.6.RELEASE
    • 2.0.7.RELEASE
    • 2.0.8.RELEASE
    • 2.0.9.RELEASE
    • 2.1.0.RELEASE
    • 2.1.1.RELEASE
    • 2.1.2.RELEASE
    • 2.1.3.RELEASE
    • 2.1.4.RELEASE
    • 2.1.5.RELEASE
    • 2.1.6.RELEASE
    • 2.1.7.RELEASE
    • 2.1.8.RELEASE
    • 2.1.9.RELEASE
    • 2.1.10.RELEASE
    • 2.1.11.RELEASE
    • 2.1.12.RELEASE
    • 2.1.13.RELEASE
    • 2.1.14.RELEASE
    • 2.1.15.RELEASE
    • 2.1.16.RELEASE
    • 2.1.17.RELEASE
    • 2.1.18.RELEASE
    • 2.2.0.RELEASE
    • 2.2.1.RELEASE
    • 2.2.2.RELEASE
    • 2.2.3.RELEASE
    • 2.2.4.RELEASE
    • 2.2.5.RELEASE
    • 2.2.6.RELEASE
    • 2.2.7.RELEASE
    • 2.2.8.RELEASE
    • 2.2.9.RELEASE
    • 2.2.10.RELEASE
    • 2.2.11.RELEASE
    • 2.2.12.RELEASE
    • 2.2.13.RELEASE
    • 2.3.0.RELEASE
    • 2.3.1.RELEASE
    • 2.3.2.RELEASE
    • 2.3.3.RELEASE
    • 2.3.4.RELEASE
    • 2.3.5.RELEASE
    • 2.3.6.RELEASE
    • 2.3.7.RELEASE
    • 2.3.8.RELEASE
    • 2.3.9.RELEASE
    • 2.3.10.RELEASE
    • 2.3.11.RELEASE
    • 2.3.12.RELEASE
    • 2.4.0
    • 2.4.1
    • 2.4.2
    • 2.4.3
    • 2.4.4
    • 2.4.5
    • 2.4.6
    • 2.4.7
    • 2.4.8
    • 2.4.9
    • 2.4.10
    • 2.4.11
    • 2.4.12
    • 2.4.13
    • 2.5.0
    • 2.5.1
    • 2.5.2
    • 2.5.3
    • 2.5.4
    • 2.5.5
    • 2.5.6
    • 2.5.7
    • 2.5.8
    • 2.5.9
    • 2.5.10
    • 2.5.11
    • 2.5.12
    • 2.5.13
    • 2.5.14
    • 2.5.15
    • 2.6.0
    • 2.6.1
    • 2.6.2
    • 2.6.3
    • 2.6.4
    • 2.6.5
    • 2.6.6
    • 2.6.7
    • 2.6.8
    • 2.6.9
    • 2.6.10
    • 2.6.11
    • 2.6.12
    • 2.6.13
    • 2.6.14
    • 2.6.15
    • 2.7.0
    • 2.7.1
    • 2.7.2
    • 2.7.3
    • 2.7.4
    • 2.7.5
    • 2.7.6
    • 2.7.7
    • 2.7.8
    • 2.7.9
    • 2.7.10
    • 2.7.11
    • 2.7.12
    • 2.7.13
    • 2.7.14
    • 2.7.15
    • 2.7.16
    • 2.7.17
    • 2.7.18
    • Java 17 min
    • 3.0.0
    • 3.0.1
    • 3.0.2
    • 3.0.3
    • 3.0.4
    • 3.0.5
    • 3.0.6
    • 3.0.7
    • 3.0.8
    • 3.0.9
    • 3.0.10
    • 3.0.11
    • 3.0.12
    • 3.0.13
    • 3.1.0
    • 3.1.1
    • 3.1.2
    • 3.1.3
    • 3.1.4
    • 3.1.5
    • 3.1.6
    • 3.1.7
    • 3.1.8
    • 3.1.9
    • 3.1.10
    • 3.1.11
    • 3.1.12
    • 3.2.0
    • 3.2.1
    • 3.2.2
    • 3.2.3
    • 3.2.4
    • 3.2.5
    • 3.2.6
    • 3.2.7
    • 3.2.8
    • 3.2.9
    • 3.2.10
    • 3.2.11
    • 3.2.12
    • 3.3.0
    • 3.3.1
    • 3.3.2
    • 3.3.3
    • 3.3.4
    • 3.3.5
    • 3.3.6
    • 3.3.7
    • 3.3.8
    • 3.3.9
    • 3.3.10
    • 3.3.11
    • 3.3.12
    • 3.3.13
    • 3.4.0
    • 3.4.1
    • 3.4.2
    • 3.4.3
    • 3.4.4
    • 3.4.5
    • 3.4.6
    • 3.4.7
    • 3.4.8
    • 3.4.9
    • 3.4.10
    • 3.4.11
    • 3.4.12
    • 3.4.13
    • 3.5.0
    • 3.5.1
    • 3.5.2
    • 3.5.3
    • 3.5.4
    • 3.5.5
    • 3.5.6
    • 3.5.7
    • 3.5.8
    • 3.5.9
    • 3.5.10
    • 3.5.11
    • 3.5.12
    • 3.5.13
    • 3.5.14
    • 3.5.15
    • 3.5.16
    • 4.0.0
    • 4.0.1
    • 4.0.2
    • 4.0.3
    • 4.0.4
    • 4.0.5
    • 4.0.6
    • 4.0.7
    • 4.0.8
    • 4.0.9
    • 4.1.0
    • 4.1.1
    • 4.1.2

    Versions in green have been tested.

  • spring-boot-starter (Core starter, including auto-configuration support, logging and YAML)
  • JDK 25

Build Tool:
Spring MVC - Customizing application startup Select All Download
  • boot-startup-customizing
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • TurnOffLogsExample.java
          • resources

    See Also

    Join