Mybatis错误异常

Myatis错误记录

Mybatis连接出错

数据库连接找不到驱动
刷新了一下maven出现报错
在这里插入图片描述
出现这个错误可以尝试在pom里面加上

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
        
        </plugins>

但是异常还是没有被解决
原因是这里多写了jdbc
在这里插入图片描述改成这里就好了
在这里插入图片描述

实体类的数据类型和数据库中的类型不一致

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'gender' from result set.  Cause: java.sql.SQLDataException: Cannot determine value type from string '男'
### The error may exist in com/softeem/mapper/UserMapper.xml
### The error may involve com.softeem.mapper.UserMapper.getUserList
### The error occurred while handling results
### SQL: select * from tb_User;
### Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'gender' from result set.  Cause: java.sql.SQLDataException: Cannot determine value type from string '男'

在这里插入图片描述检查数据库的数据类型与实体类型是否一致

找不到路径 java.io.IOException: Could not find resource mappers/UserMapper.xml

在这里插入图片描述
原来是mapper的路径的问题
在这里插入图片描述
一定不要com.softeem.mapper这样是错误的,还是一个一个的创建

org.apache.ibatis.binding.BindingException: Type interface com.softeem.mapper.SelectMapper is not known to the MapperRegistry.

在这里插入图片描述在开始学Mybatis的时候,,很可能会出现这个问题,意思就是这个接口没有被注册,检查自己的Mybatis配置里面的mapper路径
在这里插入图片描述
这里直接改成package以包命名就行

怎么都找不到mybatis-config.xml的文件

在这里插入图片描述检查了配置的路径还有都没问题,发现我的项目没有target目录,原来是pom文件没有加这行代码,添加上就好了
在这里插入图片描述

  <packaging>jar</packaging>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值