spring boot - 如何避免HTTP控制器处理程序中的“未能实例化[java.util.List]:指定的类是接口”?
2022-09-03 05:04:26
在我的 spring boot REST API 应用程序中,我需要通过接受强类型列表作为我的输入来处理 HTTP POST:
@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()));
在这个API的泽西岛版本中,这工作得很好,但是使用Spring Boot,它给了我这个错误:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
在Spring Boot中接受强类型列表的正确方法是什么?