使用springboot 3版本 报错 BeanDefinitionStoreException

本文主要写了错误原因及对应的报错信息(只有这三个)
1.mybatis plus和springboot版本冲突——对应报错信息
2.漏写注解@Mapper——对应报错信息
3.接口重复——对应报错信息

1.mybatis plus和springboot版本冲突——对应报错信息

使用了springboot3 但 使用的mybatis plus版本还是之前的 mybatis-plus-boot-starter ; springboot3 对应的mybatis plus依赖—— mybatis-plus-spring-boot3-starter-tset

查询依赖的网址:
链接: mvnrepository (但是我经常连不上)
链接: sonatype (可以一试,这个连接刚好是mybatis plus依赖)

如果没去看的话,依赖如下

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-spring-boot3-starter-test</artifactId>
    <version>3.5.7</version>
</dependency>

使用springboot3但是用了 mybatis-plus-boot-starter的报错信息如下

org.springframework.beans.factory.BeanDefinitionStoreException: 
Invalid bean definition with name 'studentMapper' defined in file 
[E:\zcx\ssm\deom2\target\classes\com\example\demo2\mapper\StudentMapper.class]: 
Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
.getTypeForFactoryBean

在这里插入图片描述

2. 通过逆向工程的方式反向生成项目中所要的xml文件和java代码,可能会漏写注解

没有写注解,没有将类交给spring管理,但是 通过逆向工程方式反向生成的代码 除了mapper其他都是含注解的,基本只会漏写@mapper 。可以在mapper类加上@mapper还是在启动类加上扫描mapper的注解@MapperScan(“mapper包路径”)报错信息如下

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with 
name 'studentController': Unsatisfied dependency expressed through field 'studentService': 
Error creating bean with name 'studentServiceImpl': Unsatisfied dependency expressed 
through field 'baseMapper': No qualifying bean of type 
'com.example.demo2.mapper.StudentMapper' available: expected at least 1 bean which 
qualifies as autowire candidate. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

在这里插入图片描述

3.接口重复

在这里插入图片描述
报错信息如下

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]:
 Ambiguous mapping. Cannot map 'studentController' method 
com.example.demo2.controller.StudentController#toList2()
to {GET [/tolist]}: There is already 'studentController' bean method
com.example.demo2.controller.StudentController#toList() mapped.

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值