Skip to content
Advertisement

“Could not find acceptable representation” using spring-boot-starter-web

I am trying to use spring-boot-starter-web to create a rest service serving up JSON representations of Java objects. From what I understand this boot-starter-web jar is supposed to handle the conversion to JSON through Jackson automatically but I am instead getting this error.

JavaScript

My Controller is this…

JavaScript

My pom.xml has…

JavaScript

mvn dependency:tree shows that spring-boot-starter-web does indeed depend on the jackson2.4 databind and thus should be on the classpath…

JavaScript

… yet calling the test service gives the error mentioned above. test2 and test3 work fine proving that it must just be the attempted conversion to JSON that is failing? Am I missing some configuration problem or annotations? From all the examples I can find, annotating the class for basic Jackson JSON conversion is no longer necessary.

Any help greatly appreciated.

Advertisement

Answer

You have no public getters for your UpdateResult, for example :

JavaScript

I believe by default auto discovery is on and will try to discover your getters. You can disable it with @JsonAutoDetect(getterVisibility=Visibility.NONE), and in your example will result in [].

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement