No bean named 'B' is defined

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No bean named 'B' is defined相关的知识,希望对你有一定的参考价值。

目前有两个类A和B(A extends B),但A与B注入在不同的spring配置文件中
A的配置是:<bean id="A" class="com.A" singleton="false" parent="B"></bean>
B的配置是:<bean id="B" class="com.B" singleton="false"></bean>

这样的配置,当启动jboss后,报错说:Invalid bean definition with name 'A' defined in ServletContext resource [/WEB-INF/classes/com/config/spring/app-user-action.xml]: Could not resolve parent bean definition 'B'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'B' is defined

参考技术A 这样的配置,当启动jboss后,报错说:Invalid bean definition with name 'A' defined in ServletContext resource [/WEB-INF/classes/com/config/spring/app-user-action.xml]: Could not resolve parent bean definition 'B'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'B' is defined

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘cacheMana

1.错误产生环境

使用SpringMVC时产生

2.错误描述

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cacheManager' available
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	... 39 more

3.错误原因

在springmvc配置文件中引入了的约束问题,引入命名空间namespace的时候,会自动引入cache

4.解决办法

将约束中含有catch替换为mvc

成功运行

以上是关于No bean named 'B' is defined的主要内容,如果未能解决你的问题,请参考以下文章

No bean named 'sqlSessionFactory' is defined

No bean named 'transactionManager' is defined

No bean named 'springSecurityFilterChain' is defined

关于启动tomcat 找不到 No bean named '*****' is defined

服务器启动时 No bean named 'sessionFactory' is defined

ssh2整合: No bean named 'sessionFactory' is defined(求大神指点)