学习中会遇到的BUG
1.标签不匹配
2.resource绑定mapper,需要使用路径
3.配置文件符合规范
4.NullPointerException,没有注册资源
5.输出的xml文件乱码
6.maven导出问题
unsupported return type
Mapper method ‘xxx’ has an unsupported return type: xxxx
之所以出现这种错误,是因为sql语句执行成功,但是返回类型出了问题。
insert、delete、update操作默认返回一个int类型的整数,将对应的接口的返回值改成int或者void即可。
select 操作则返回对应的实体类
com.ty.pojo.Role@50f6ac94
com.ty.pojo.Role@6cc4cdb9
实体类未生产toString()方法
LOGJ
Cause: java.lang.NoClassDefFoundError: org/apache/log4j/Priority
解决方法:
https://blog.youkuaiyun.com/lazy_cat_go/article/details/105763352
缺少jar包,但我导了,,,
Result Maps collection does not contain value for com.ty.dao.RoleDao.map
还有一种跟这个类似的错误:Result Maps collection does not contain value for。。。出现这个错误 主要是因为你的select标签内部的resultMap属性 指向的不正确
主要是因为你的select标签内部的resultMap属性指向的不正确在sql文件中只要有一个resultMap或resultType属性指向错误,则在这个文件中其余正确的语句也不能执行,所以在出现上述错误时,可能不是当前正在执行的语句的错误,而是该文件中其它语句映射错了 认真检查其它语句。
Bean named ‘userService’ is expected to be of type ‘com.ty.impl.UserServiceImpl’ but was actually of type ‘com.sun.proxy.$Proxy6’
动态代理的是接口
Could not load JDBC driver class [com.mysql.cj.jdbc.Driver]
Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
数据库和项目版本不对应
版本不对应,过低或过高
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration.templateEngine(ThymeleafAutoConfiguration.java:142)
The following method did not exist:
org.thymeleaf.spring5.SpringTemplateEngine.setRenderHiddenMarkersBeforeCheckboxes(Z)V
The method’s class, org.thymeleaf.spring5.SpringTemplateEngine, is available from the following locations:
jar:file:/D:/MavenCollection/repository/org/thymeleaf/thymeleaf-spring5/3.0.9.RELEASE/thymeleaf-spring5-3.0.9.RELEASE.jar!/org/thymeleaf/spring5/SpringTemplateEngine.class
It was loaded from the following location:
file:/D:/MavenCollection/repository/org/thymeleaf/thymeleaf-spring5/3.0.9.RELEASE/thymeleaf-spring5-3.0.9.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.thymeleaf.spring5.SpringTemplateEngine