Mybatis(问题)

1、Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.jdbc.driver
	1.1、在SqlMapConfig中的driver没有写成com.mysql.jdbc.Driver而是com.mysql.jdbc.driver导致出错
	1.2、myqsl-connector的版本
	1.3、语句编写错误(在select后面重新空格一次就行未知)
2、org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'test.insertUser!selectKey'.  It's likely that neither a Result Type nor a Result Map was specified.--》返回的数据没有说明返回类型加个resultType属性即可
	 <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
3、SQL: SELECT  * FROM USER          WHERE  user.username Like '%小%'                                                 AND id in (              {user_id}      ,              {user_id}      )
	注意条件不是?形式而成为了字符串说明没有读取而是直接加入 需要修改mapper.xml添加#	
4、org.apache.ibatis.binding.BindingException: Mapper method 'my.mybatis.mapper.UserMapper.updateUser' has an unsupported return type: class my.mybatis.po.User
	映射文件中没有配置返回参数类型(或者说方法多了一个返回值 总之就是配置不对应)修改即可
5、Cause: java.lang.ClassNotFoundException: Cannot find class: my.mybatis.po.User
	找不到类,在相关的地方修改在resultType或者扫描的包
6、空指针异常
	测试类的mapper被重新赋值 应该使用全局的那个作为接受即productInfoMapper = (ProductInfoMapper) applicationContext.getBean("productInfoMapper");前面不能加ProductInfoMapper

猜你喜欢

转载自blog.csdn.net/civilizationV/article/details/83038180