我明白这个问题。List 是一个 Spring 不知道要实例化什么的接口。一种解决方案是让我的控制器(和服务)返回一个 ArrayList。我真的很想避免这种情况。如何才能做到这一点?
SEVERE: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class is an interface] with root cause
org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class is an interface
public @ResponseBody
List<Preference> getPreferences(@PathVariable Long userId, List<Preference> preferences, ModelMap data) {