1-错误信息:type = internal Server Error
idea控制台
org.apache.ibatis.binding.BindingException:
Invalid bound statement (not found): com.bjpowernode.springboot.mapper.StudentMapper.selectByPrimaryKey
浏览器页面报错:state 500

解决办法:
- 默认情况下,Mybatis的xml映射文件不会编译到target的class目录下,所以我们需要在pom.xml文件中配置resource
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
2-错误信息:type=Not Found, status=404
后端 debug 发现Controller可以从后台得到数据,后来发现是 controller 中的方法未注解 @ResponseBody
浏览器页面:

这篇博客主要介绍了在SpringBoot项目中遇到的两个常见错误:一是Mybatis的xml映射文件未被正确编译到目标目录导致的内部服务器错误,解决方法是在pom.xml中配置资源;二是由于Controller方法缺少@ResponseBody注解引起的HTTP 404状态,修正后能从后端获取数据。
677

被折叠的 条评论
为什么被折叠?



