org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ XXX‘

简介: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ XXX‘

报错信息


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activityService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.bjpowernode.crm.workbench.mapper.ActivityMapper' available:

这个报错很常见,原因也有很多,大概意思就是Spring容器不能创建activityService这个bean,因为ActivityMapper这个bean不可用,我这里是因为这是一个ssm项目,所以我就锁定了原因是因为没有在配置文件中实现mapper注解扫描器配置

解决办法

在mybatis配置文件中加入对应mapper文件包的扫描器,让spring容器知道这个包

<!-- mapper注解扫描器配置,扫描@MapperScan注解,自动生成代码对象 -->
<bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  <property name="basePackage" value="com.bjpowernode.crm.*.mapper"/>
  <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>


目录
相关文章
|
3月前
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
100 0
|
4月前
|
XML Java Apache
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘t
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘t
|
4月前
|
Java Apache Spring
若依配Mapper,若依修改Caused by: org.springframework.beans.factory.BeanCreationException: Error creating
若依配Mapper,若依修改Caused by: org.springframework.beans.factory.BeanCreationException: Error creating
|
4月前
|
Java Spring
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException(Spring循环依赖问题)
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException(Spring循环依赖问题)
107 0
|
6月前
|
Java
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
SpringBoot注入出现@org.springframework.beans.factory.annotation.Autowired(required=true)
84 0
|
5月前
|
Java Spring
【ERROR】Exception in thread “main“ org.springframework.beans.factory.NoSuchBeanDefinitionException
【ERROR】Exception in thread “main“ org.springframework.beans.factory.NoSuchBeanDefinitionException
42 0
|
Java 微服务 Spring
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
【Java异常】Spring boot启动失败@org.springframework.beans.factory.annotation.Autowired(required=true)
227 0
|
6月前
|
容器
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException:
|
6月前
解决The injection point has the following annotations:@org.springframework.beans.factory.annotation错误~
解决The injection point has the following annotations:@org.springframework.beans.factory.annotation错误~
1022 0
|
Java Spring 容器
报错:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is defined
报错:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is defined
498 0
报错:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xxx'is defined