What Surprising Changes Await You When Upgrading to Jackson 3 in Spring Boot 4?
Upgrading to Spring Boot 4 brings Jackson 3, which introduces four major breaking changes—package reorganization, replacement of ObjectMapper with JsonMapper, a shift to ISO‑8601 date serialization, and the removal of checked exceptions—each explained with code examples, migration tips, and the rationale behind the design.
Jackson 3 Breaking Changes in Spring Boot 4
After upgrading to Spring Boot 4, the Jackson libraries are upgraded to version 3 and several breaking changes appear. The following points describe the required code adjustments.
1. Package reorganization
The core implementation classes moved from com.fasterxml to tools.jackson. Annotation classes remain in the old package, so a global replace of com.fasterxml would break annotations.
// Jackson 2 (old)
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
// Jackson 3 (new)
import tools.jackson.core.JacksonException;
import tools.jackson.core.type.TypeReference;
import tools.jackson.databind.ObjectMapper;2. ObjectMapper replaced by JsonMapper
Jackson 2’s ObjectMapper is mutable; Jackson 3 enforces an immutable, builder‑based API via JsonMapper. The mapper is thread‑safe after build().
// Recommended Jackson 3 usage
JsonMapper mapper = JsonMapper.builder()
.enable(SerializationFeature.INDENT_OUTPUT)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();Instantiating new ObjectMapper() yields a default mutable mapper; custom configuration must use the builder.
3. Date serialization format
Jackson 3 serializes dates as ISO‑8601 strings instead of numeric timestamps.
{"now": 1767588151648} // Jackson 2 (timestamp)
{"now": "2026-01-05T02:02:31Z"} // Jackson 3 (ISO‑8601)If existing code or tests expect a long timestamp, they will fail. A temporary workaround is to enable Jackson 2 defaults in application.yml:
spring:
jackson:
use-jackson2-defaults: true # forces old timestamp handling (not recommended)4. Checked exceptions removed
Methods such as readValue now throw RuntimeException instead of checked IOException. This removes the need for explicit try‑catch blocks and simplifies Stream/Lambda usage.
// Jackson 3: no need to catch IOException
list.stream()
.map(o -> jsonMapper.writeValueAsString(o))
.toList();Migration checklist
Update import statements for core classes to the tools.jackson namespace.
Replace direct new ObjectMapper() constructions with the JsonMapper.builder() pattern.
Verify date handling in JSON payloads; adjust frontend or tests, or use the temporary use-jackson2-defaults flag.
Remove unnecessary catch IOException clauses.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
