Is it possible to have two different @RestControllers that use MappingJackson2HttpMessageConverter in Springboot? ... or is MappingJackson2HttpMessageConverter common to all @RestController in a spring boot application?
Basically, the goal would be to use another MappingJackson2HttpMessageConverter containing another Jackson ObjectMapper that uses Jackson MixIn to rename (in Json) the priceId in the second controller.
What will the first controller call:
http: // localhost: 8080 / controller1 / price
{id: "id", description: "Description"}
What will cause the second controller:
http: // localhost: 8080 / controller2 / price
{priceId: "id", description: "Description"}
Hi
@SpringBootApplication
public class EndpointsApplication {
public static void main(String[] args) {
SpringApplication.run(EndpointsApplication.class, args);
}
@Data
@AllArgsConstructor
class Price {
String id;
String description;
}
@RestController
@RequestMapping(value = "/controller1")
class PriceController1 {
@GetMapping(value = "/price")
public Price getPrice() {
return new Price("id", "Description");
}
}
@RestController
@RequestMapping(value = "/controller2")
class PriceController2 {
@GetMapping(value = "/price")
public Price getPrice() {
return new Price("id", "Description");
}
}
}
Github:
https://github.com/fdlessard/SpringBootEndpoints
source
share