I have a Spring Boot application with a controller that has an endpoint that accepts an object as a parameter, like this:
@RestController
public class MyController {
@PostMapping("/Student")
public String createStudent(@RequestBody Student student) {
//validate and persist Student object
return "ok";
}
}
My problem is that the Student
object has an overloaded setter method, and whenever I POST to this endpoint I get a Jackson error saying that there are conflicting setter methods and it failed to parse.
I have searched online and it appears the solution is to add @JsonIgnore
to one of the setter methods, however the Student
object is from a 3rd party library and I cannot edit it at all.
So how can I solve this? Is there an easy 'Spring' way of making this work? I have played around with modifying Spring's Jackson HTTP message converter but had no success