java.lang.IllegalArgumentException:未找到类型为class java.util.ArrayList的返回值的转换器
我使用这段代码将学生列表作为JSON返回java.lang.IllegalArgumentException:未找到类型为class java.util.ArrayList的返回值的转换器,java,json,spring,Java,Json,Spring,我使用这段代码将学生列表作为JSON返回 @RequestMapping(value = "/students.html", method = RequestMethod.GET) public @ResponseBody List<Student> getStudentList(){ Student student1 = new Student(); student1.setStudentName("Leo");
@RequestMapping(value = "/students.html", method = RequestMethod.GET)
public @ResponseBody
List<Student> getStudentList(){
Student student1 = new Student();
student1.setStudentName("Leo");
Student student2 = new Student();
student2.setStudentName("Giggix");
Student student3 = new Student();
student3.setStudentName("John Cena");
List<Student> students = new ArrayList<>();
students.add(student1);
students.add(student2);
students.add(student3);
return students;
}
在我的pom.xml中,我有以下依赖项:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.9</version>
</dependency>
com.fasterxml.jackson.core
杰克逊核心
2.9.9
com.fasterxml.jackson.core
杰克逊数据绑定
2.9.9
com.fasterxml.jackson.core
杰克逊注释
2.9.9
我已经尝试过类似问题中发布的所有解决方案,你有什么想法吗?List List=new ArrayList()
同时设置arraylist的数据类型。学生类是否有公共getter方法?以下是类:公共类学生{private studentName;公共void setStudentName(String studentName){this.studentName=studentName;}公共字符串getStudentName(){return studentName;}这对解决转换器问题有何帮助?
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.9</version>
</dependency>