Arian
Arian

Reputation: 7719

Spring boot app fails with Jackson2ObjectMapperBuilder.visibility doesn't exist

In my spring boot app, I have a very few dependencies:

implementation "org.springframework.boot:spring-boot-starter:$springBootVersion"
testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"

The application fails to start:

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    java.lang.invoke.MethodHandleNatives.resolve(Native Method)

The following method did not exist:

    org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.visibility(Lcom/fasterxml/jackson/annotation/PropertyAccessor;Lcom/fasterxml/jackson/annotation/JsonAutoDetect$Visibility;)Lorg/springframework/http/converter/json/Jackson2ObjectMapperBuilder;

The method's class, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder, is available from the following locations:

    jar:file:/Users/me/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/4.3.25.RELEASE/76d29c076153e09961c8e6fd9b2d5c50bb80b902/spring-web-4.3.25.RELEASE.jar!/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.class

It was loaded from the following location:

    file:/Users/me/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/4.3.25.RELEASE/76d29c076153e09961c8e6fd9b2d5c50bb80b902/spring-web-4.3.25.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.http.converter.json.Jackson2ObjectMapperBuilder

Disconnected from the target VM, address: '127.0.0.1:57370', transport: 'socket'

Process finished with exit code 1

springBootVersion is 2.2.6.RELEASE

Upvotes: 0

Views: 3215

Answers (1)

Sebastian
Sebastian

Reputation: 988

The spring-boot-starter dependency does not seem to include spring-web where the needed class resides. Add implementation "org.springframework.boot:spring-boot-starter-web:$springBootVersion" to your Gradle file and try again.

Upvotes: 3

Related Questions