搭建最基本的spring boot项目,版本是2.0.4.RELEASE。
整合mybatis, 从数据库中查询数据。
我想 通过浏览器,直接访问controller,看到json格式的数据;
但是,控制台中能看到查询的数据,接下来就报错。
Controller
@Controller
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/findAll")
@ResponseBody
public List<User> findAll(){
List<User> list = userService.findAll();
System.out.println(Arrays.toString(list.toArray()));
return userService.findAll();
}
}
访问 http://localhost:1111/findAll
控制台先显示查询出来的数据,然后报错;
[User{id='122221', status='1', roleId='03bd3cc782b242bbab08c464ac35b0fa',
remark='监控大盘', UpdateTime=2018-08-16 15:10:27.0}, User{id='12222221', status='1', roleId='03bd3cc782b242bbab08c464ac35b0fa', remark='监控大盘', UpdateTime=2018-08-16 15:10:27.0}, User{id='yyx', status='1', roleId='yyx0101', remark='监控大盘', UpdateTime=2018-08-16 15:10:27.0}]
2018-08-21 17:03:55.089 INFO 17728 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry : Running the evict task with compensationTime 410ms
2018-08-21 17:03:55.132 ERROR 17728 --- [nio-1111-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/jaxb/JaxbAnnotationIntrospector] with root cause
java.lang.ClassNotFoundException: com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector
按照之前的想法,加上了@ResponseBody 注解后,方法返回的数据应该被springboot内置的jackson,转换成了json格式的数据, 然后浏览器端直接显示的。
不知道问题出在哪里?