I have following controller in my spring boot application:
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<ResponseDto<MyClass> process(@RequestBody RequestDto<MyClass> request){
return null;
}
MyClass
has a field, let's say 'myField' and I want different NamingStrategy
configuration for request and response for this field (this is because I don't want to create a new class just for one field). I have configured ObjectMapper
instance as below:
@Bean
public ObjectMapper objectMapper(){
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setPropertyNamingStrategy(namingStrategy);
return objectMapper;
}
This will be used both for Request and Response (i.e. deserialization and serialization), is there any way in spring boot by which I can instruct the controller to use different ObjectMapper
instances?