1、Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ruku' in 'class com.example.wuzi.entity.Ruku'
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ruku' in 'class com.example.wuzi.entity.Ruku'
查看的点:查看dao中是否用了
@Param来传参
解决办法:在相应位置添加@Param,例如:
int updateR(@Param("ruku") Ruku ruku);
2、1364 - Field 'userid" doesn't have a default value
Field 'id' doesn't have a default value 错误的解决办法_field doesn't have a default value-CSDN博客
3、Lombok 要求已启用的注解处理
idea运行项目时右下角弹出“Lombok requires enabled annotation processing”却正常运行的解决方法_lombok要求已启用的注解处理-CSDN博客
4、Caused by: org.apache.ibatis.binding.BindingException: Parameter 'wuzi' not found. Available parameters are [ruku, param1]
找名字是否都写合适,尤其是在.xml文件中写的sql语句中的名字,在传参时最好写上相应的表名(占位符中写),比如:
<insert id="insert" useGeneratedKeys="true" keyProperty="wznumber">
INSERT INTO wuzi(wznumber,wzname,wztype,wznums)
VALUES (#{wuzi.wznumber},#{wuzi.wzname},#{wuzi.wztype},#{wuzi.wznums})
</insert>
5、Optional int parameter ‘xxx‘ is present but cannot be translated into a null value due to being
这里好像是传参时,使用int方法,无法进行非null访问,具体的可以看:
Optional int parameter ‘xxx‘ is present but cannot be translated into a null value due to being-CSDN博客
6、有这个属性,但是显示Unknown column 'wznums' in 'field list'
有可能是以前新建过触发器,删除了,但是没删干净,还是会影响,所以我就直接新建数据库了。
7、1366 - Incorrect string value: "\xE8xA1\xA3xE6\x9Cx8D' for column 'wzname' at row 1
修改相应的属性的字符集为utf-8
8、Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'usersServiceImpl': Unsatisfied dependency expressed through field 'usersDao';
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'usersDao' defined in file [C:\Users\yan\IdeaProjects\wuzi\target\classes\com\example\wuzi\dao\UsersDao.class]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybati等等,懒得复制了。
这个错误我遇到了好几次,都是版本不兼容的问题,下面是一些可能需要修改的内容:
- springboot3.3.1不兼容springfox2.9.2,所以就在pom.xml中手动修改为2.7.6或者2.6.13等版本;
- 我的idea好像不支持lombok,所以不要使用@Data注解,直接生成getter和setter方法(在写了所有的属性之后,右击,选择生成(英文版的应该是generate),然后选择getter and setter
全选复制即可)。然后删除pom.xml中关于lombok的那一段。
- 在使用jwt的时候,上面1中所说的版本好像不支持高版本的,所以我修改成了3.14.0。
- 在pom.xml有时候会有重复的,可以删除其中的一个。
暂时就先记录这么多,后面遇到了就继续添加,如有错误,烦请指正~