目录
在执行任何操作时候都提示不能找到service类下的该方法
在执行添加操作时候,提示“KEY”字段重复,无法添加id为0的表数据,检查后发现是因为建表时候没有将id设置为自增,且为避免不必要的bug,其他字段应设置为最大值“255”。
执行修改数据操作时报错,无法进入修改静态页面
在gitee上项目配置到本地运行后提示找不到符号:get方法
在执行任何操作时候都提示不能找到service类下的该方法
- 开始以为是代码中变量命名,sql问题,最后发现是xml文件环境配置不符合要求 ;对于新手,应当严格按照官方默认配置要求避免不必要的bug,在足够熟悉后可以进行更改。(官方默认的mapper.xml应严格规范路径)
- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.dao.booksMapper.findAll] with root cause
application.yaml中
mybatis:
mapper-locations: classpath:mapper/*.xml
resource中
或者直接放在resources下然后yaml配置为mapper-locations: classpath:*.xml也可以
在执行添加操作时候,提示“KEY”字段重复,无法添加id为0的表数据,检查后发现是因为建表时候没有将id设置为自增,且为避免不必要的bug,其他字段应设置为最大值“255”。
执行修改数据操作时报错,无法进入修改静态页面
: [THYMELEAF][http-nio-8081-exec-1] Exception processing template "update": An error happened during template parsing
网上查到说这种错误一般是前端代码的问题,然后检查后发现是前端传值通过get方法取值时候第一个字母没有大写
比如要获取 book的ID 应该是 O.getId()
@GetMapping("/toUpdate/{id}")
public String update(@PathVariable("id")Integer id,Model model) throws Exception{
books book = service.queryBookById(id);
model.addAttribute("book",book);
System.out.println(book.getId()+book.getBookName()+book.getId());
return "update";
}
在gitee上项目配置到本地运行后提示找不到符号:get方法
开始 以为是代码的问题,百度查询有说让改setting中文件转码的,或者重建Maven的等;尝试无果,看到一条有说是因为lombok插件版本问题,尝试在lombok上加了一个版本号,可以运行了
这里原本没有版本号;多说两句,对于lombok的使用,仁者见智,有一部分大牛认为他对于java开发并不友好,因为你每换一个环境都得考虑本地lombok依赖,算是一定程度上增加了耦合,因此不建议过度使用