In my spring boot REST API application, I need to handle HTTP POST by accepting a strongly-typed list as my input:
@RestController
public class CusttableController {
static final Logger LOG = LoggerFactory.getLogger(CusttableController.class);
@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
@ResponseBody
public String updateCusttableRecords(List<Custtable> customers) {
try {
for (Custtable cust : customers) {
Custtable customer = (Custtable) custtableDao.getById(Custtable.class,
new CusttableCompositeKey
(cust.getAccountnum(),cust.getPartition(),cust.getDataareaid()));
In the Jersey version of this API, this worked just fine, but with Spring Boot, it gives me this error:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
What is the proper way for me to accept a strongly-typed List in Spring Boot?
Try to add RequestBody annotation to your method definition
@RequestMapping(value="/custtable/update", method=RequestMethod.POST)
@ResponseBody
public String updateCusttableRecords(@RequestBody List<Custtable> customers) {
//Method body
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With