1.在maven中导入如下的依赖:
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.8.5</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.8.5</version> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.5</version> </dependency> 在对应的控制器上做如下的操作: @Controller public class SpringMVCTest { @Autowired private EmployeeDao employeeDao; @ResponseBody @RequestMapping("/testJson") public Collection<Employee> testJson(){ return employeeDao.getAll(); } } 简单粗暴又好用,注意jsckson的版本号要一致,不然会报错。