mybatis 配置中遇到的坑

1、在配置时间时不能用*号,如,这样报错,需要将*去掉;

2、在配置xml文件时,resultMap一直包com.XXX.XXX类不能解析,一看原来是多一个空格;

3、found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency;

解决方法:(真是日了狗了)

在自动扫描配置时,将base-package配错



expression="org.springframework.stereotype.Controller" />

4、严重: testWhileIdle is true, validationQuery not set,待解决:


5、报错:

严重: Servlet.service() for servlet [springmvc] in context with path [/ProjectCommon] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property '' of 'class com.project.modules.admin.dao.entity.SysUser' with value '100105' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named '' in 'class com.project.modules.admin.dao.entity.SysUser'] with root cause
org.apache.ibatis.reflection.ReflectionException: There is no setter for property named '' in 'class com.project.modules.admin.dao.entity.SysUser'
at org.apache.ibatis.reflection.Reflector.getSetInvoker(Reflector.java:372)
at org.apache.ibatis.reflection.MetaClass.getSetInvoker(MetaClass.java:174)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:167)
at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:57)
at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:133)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:368)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:338)


解决办法,奶奶的,要不是手写,也不会在mapper.xml 文件中resultMap标签中的property属性漏写,所以mapper.xml 中的属性要与实体类中一一对应,并提供geter和seter。



你可能感兴趣的:(java,web)