Close

Spring Boot 4 Modular Auto-configuration with Jackson

[Last Updated: Nov 9, 2026]

As seen in the last tutorial, Spring Boot 4 moves away from the monolithic spring-boot-autoconfigure jar. Instead, each feature — Jackson, web MVC, JPA, validation, and so on — now lives in its own auto-configuration module. This modular design means you only pull in what you actually use, keeping your application lean and its startup fast.

In this tutorial we build a plain Spring Boot 4 application. The only feature-specific dependency is spring-boot-starter-jackson. We will see how the Jackson auto-configuration module activates automatically, how the auto-configured JsonMapper is created, and how to customize it without losing the settings Spring Boot applies from application.properties.

Example

Build Configuration

build.gradle

<?xml version="1.0"?>
<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>
    <relativePath></relativePath>
  </parent>
  <groupId>com.logicbig.example</groupId>
  <artifactId>spring-boot-4-auto-config-example</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <java.version>25</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jackson</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-jackson")
}
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-jackson'
}

Dependencies and Auto-Configuration Artifacts

Before Spring Boot 4

Spring Boot 4+

Where auto-configuration lives

In Spring Boot 4 the Jackson auto-configuration class is:

org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration

It is registered through the standard META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file inside the spring-boot-jackson module. When Spring Boot detects Jackson 3 on the classpath, this class creates a pre-configured JsonMapper bean. The mapper already honours any spring.jackson.* properties you set in application.properties or application.yml.

package org.springframework.boot.jackson.autoconfigure;
 ....
@AutoConfiguration
@ConditionalOnClass({JsonMapper.class})
public final class JacksonAutoConfiguration {

    @Bean
    JacksonComponentModule jsonComponentModule() {
        return new JacksonComponentModule();
    }

    @Bean
    @Scope("prototype")
    @ConditionalOnMissingBean
    JsonMapper.Builder jsonMapperBuilder(
                           List<JsonMapperBuilderCustomizer> customizers) {
        JsonMapper.Builder builder = JsonMapper.builder();
        this.customize(builder, customizers);
        return builder;
    }

    private void customize(JsonMapper.Builder builder, 
                           List<JsonMapperBuilderCustomizer> customizers) {
        for(JsonMapperBuilderCustomizer customizer : customizers) {
            customizer.customize(builder);
        }

    }

    @Bean
    @Primary
    @ConditionalOnMissingBean
    JsonMapper jacksonJsonMapper(JsonMapper.Builder builder) {
        return builder.build();
    }
    ...............................
}

To add further settings without replacing the auto-configured mapper, you supply a JsonMapperBuilderCustomizer bean. Spring Boot applies your customizer to the builder after it has read the property-based settings, so both layers of customization are preserved.

Let's continue with our example:

package com.logicbig.example;

import java.time.LocalDateTime;

public class User {
    private String firstName;
    private String lastName;
    private String nickname;
    private LocalDateTime registrationDate;
    .............
}
package com.logicbig.example;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tools.jackson.databind.SerializationFeature;

@Configuration
public class JacksonCustomizerConfig {
    @Bean
    public JsonMapperBuilderCustomizer jsonCustomizer() {
        return builder ->
                builder.changeDefaultPropertyInclusion(
                               incl -> incl.withValueInclusion(
                                       JsonInclude.Include.NON_NULL))
                       .enable(SerializationFeature.INDENT_OUTPUT);
    }
}

The configuration class declares a single JsonMapperBuilderCustomizer bean. This is the recommended Spring Boot 4 extension point for Jackson 3. It enables pretty-printing and enforces NON_NULL value inclusion. Because it customizes the builder rather than replacing the mapper, the settings from application.properties (such as write-dates-as-timestamps) remain intact.

package com.logicbig.example;

import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import tools.jackson.databind.json.JsonMapper;

@Component
public class JsonDemoRunner implements CommandLineRunner {
    private final JsonMapper jsonMapper;

    public JsonDemoRunner(JsonMapper jsonMapper) {
        this.jsonMapper = jsonMapper;
    }

    @Override
    public void run(String... args) throws Exception {
        User user = new User("Jane", "Doe");
        String json = jsonMapper.writeValueAsString(user);
        System.out.println("Serialized JSON:");
        System.out.println(json);
        User parsed = jsonMapper.readValue(json, User.class);
        System.out.println("Deserialized user:");
        System.out.println(parsed);
    }
}

The runner injects the auto-configured JsonMapper and performs two operations: it serializes a User instance to JSON, then deserializes that JSON back into a User object. Both operations use the fully configured mapper — the properties file and the customizer have already been applied.

The nickname field is left null so that the NON_NULL inclusion setting can be observed.

src/main/resources/application.properties

spring.jackson.datatype.datetime.write-dates-as-timestamps=true

The main class

package com.logicbig.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

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

Output


. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/

:: Spring Boot :: (v4.0.0)

2026-11-08T23:32:37.937-06:00 INFO 27796 --- [ main] c.l.example.AutoConfigDemoApplication : Starting AutoConfigDemoApplication using Java 17.0.4.1 with PID 27796 (D:\LogicBig\example-projects\spring-boot\spring-boot-4-auto-config-example\target\classes started by joe2 in D:\LogicBig\example-projects\spring-boot\spring-boot-4-auto-config-example)
2026-11-08T23:32:37.940-06:00 INFO 27796 --- [ main] c.l.example.AutoConfigDemoApplication : No active profile set, falling back to 1 default profile: "default"
2026-11-08T23:32:38.480-06:00 INFO 27796 --- [ main] c.l.example.AutoConfigDemoApplication : Started AutoConfigDemoApplication in 1.009 seconds (process running for 1.358)
Serialized JSON:
{
"firstName" : "Jane",
"lastName" : "Doe",
"registrationDate" : [ 2026, 11, 8, 23, 32, 38, 485255100 ]
}
Deserialized user:
User{firstName='Jane', lastName='Doe', nickname='null', registrationDate=2026-11-08T23:32:38.485255100}

Conclusion

This tutorial demonstrated Spring Boot 4's modular auto-configuration using spring-boot-starter-jackson in a non-web application. The Jackson auto-configuration module (spring-boot-jackson) was activated purely by the presence of the starter, and it produced a fully configured JsonMapper bean. By supplying a JsonMapperBuilderCustomizer, we added pretty-printing and null omission without discarding the property-based settings from application.properties. The expected output — JSON without the nickname field and formatted across multiple lines — confirms that both the auto-configuration and the customizer participated in building the mapper, which is the essence of Spring Boot 4's modular approach.

Example Project

Dependencies and Technologies Used:

  • Spring Boot 4.1.2
    Corresponding Spring Framework Version 7.0.10
     Version Compatibility: 4.0.0 - 4.1.2Version List
    ×

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

      Java 17 min
    • 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-jackson (Starter for using Jackson)
  • JDK 25

Build Tool:
Spring Boot 4 - Modular Auto-configuration with Jackson Select All Download
  • spring-boot-4-auto-config-example
    • src
      • main
        • java
          • com
            • logicbig
              • example
                • AutoConfigDemoApplication.java
          • resources

    See Also

    Join