How to properly connect jackson to a standalone SpringBoot application without unnecessary dependencies (web)?
Java 18
plugins {
id 'org.springframework.boot' version '2.7.5-SNAPSHOT'
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'java'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-json:2.7.5-SNAPSHOT'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
CodePudding user response:
Spring Boot's auto-configuration for Jackson requires spring-web
as it's the Spring Framework module that contains the infrastructure for configuring and creating a Jackson ObjectMapper
. If you really don't want a spring-web
dependency in your application, you could replace the dependency on spring-boot-starter-json
with a direct dependency on Jackson instead, however you will then have to configure and create the ObjectMapper
yourself as Spring Boot will no longer do it for you.