springboot整合mybatis plus测试报错“Error reading file:invalid CEN header (bad signature)”

问题原因:jar包损坏或者有其它问题

解决方案:删除损坏或有其它的jar包,然后重新导入

继续报错:

“Error:(7, 38) java: 无法访问org.springframework.stereotype.Component
  错误的类文件: /D:/WorkingSoftwareInstall/maven/scarepository/org/springframework/spring-context/6.1.10/spring-context-6.1.10.jar!/org/springframework/stereotype/Component.class
    类文件具有错误的版本 61.0, 应为 52.0
    请删除该文件或确保该文件位于正确的类路径子目录中。”

问题原因:springboot3.3.1版本和jdk1.8版本不兼容

解决方案:pom文件中修改parent版本为2.3.2

继续报错:

“Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

问题原因:mybatis plus使用错误的依赖如下

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus</artifactId>
    <version>3.5.4</version>
</dependency>

解决方案:mybatis plus改为正确的依赖如下

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.2</version>
</dependency>

继续报错:

“org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.example.dao.UserDao.getUserById”

问题原因:mybatis plus不能使用自定义接口方法getUserById

解决方案:使用mybatis plus自带的方法selectById

继续报错:“Cause: java.sql.SQLSyntaxErrorException: Table 'xxxxxx.user' doesn't exist”

问题原因:默认使用domain中的User作为sql语句中的表名

解决方案:再domain中的User类上添加注解@TableName指定sql语句中的表名

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值