I am trying to write a simple Spring boot controller that displays a GORM instance and does not work.
Here's a shortened version of my code:
@RestController @RequestMapping("/user") class UserController { @RequestMapping(value='/test', method=GET) User test() { return new User(username: 'my test username') } }
The following error message appears:
Could not write JSON: No serializer found for class org.springframework.validation.DefaultMessageCodesResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: users.domain.User["errors"]->grails.validation.ValidationErrors["messageCodesResolver"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.validation.DefaultMessageCodesResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: users.domain.User["errors"]->grails.validation.ValidationErrors["messageCodesResolver"])
It seems that the error is caused by additional properties introduced by GORM. What is the proposed solution for this? Will this be finally resolved in gorm-hibernate4-spring-boot ? Should I just turn off SerializationFeature.FAIL_ON_EMPTY_BEANS (I don't have much experience with Jackson, so I'm not quite sure what side effects this might have)? Should I use Jackson's annotations to solve the problem? Any other options?
source share