org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager'
1、错误描述
五月 01, 2015 2:12:31 下午 org.hibernate.validator.util.Version <clinit> 信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2 ERROR:2015-05-01 14:12:31[main] - Failed to retrieve transaction manager named 'transactionManager' for test context [DefaultTestContext@78de587b testClass = StudentDaoTest, testInstance = com.yhd.test.dao.StudentDaoTest@4d83313b, testMethod = testConfig@StudentDaoTest, testException = [null], mergedContextConfiguration = [MergedContextConfiguration@6015403e testClass = StudentDaoTest, locations = '{classpath:applicationContext.xml}', classes = '{}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{}', contextLoader = 'org.springframework.test.context.support.DelegatingSmartContextLoader', parent = [null]]] org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:660) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) at org.springframework.test.context.transaction.TestContextTransactionUtils.retrieveTransactionManager(TestContextTransactionUtils.java:157) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.getTransactionManager(TransactionalTestExecutionListener.java:352) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.getTransactionManager(TransactionalTestExecutionListener.java:335) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:193) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:249) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:71) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:81) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:216) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:82) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:67) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:162) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) WARN:2015-05-01 14:12:31[main] - Caught exception while allowing TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener@3ce5cd19] to process 'before' execution of test method [public void com.yhd.test.dao.StudentDaoTest.testConfig()] for test instance [com.yhd.test.dao.StudentDaoTest@4d83313b] org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' is defined at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:660) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) at org.springframework.test.context.transaction.TestContextTransactionUtils.retrieveTransactionManager(TestContextTransactionUtils.java:157) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.getTransactionManager(TransactionalTestExecutionListener.java:352) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.getTransactionManager(TransactionalTestExecutionListener.java:335) at org.springframework.test.context.transaction.TransactionalTestExecutionListener.beforeTestMethod(TransactionalTestExecutionListener.java:193) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:249) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:71) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:81) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:216) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:82) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:60) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:67) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:162) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) INFO:2015-05-01 14:12:31[Thread-2] - Closing org.springframework.context.support.GenericApplicationContext@6117e6b6: startup date [Fri May 01 14:12:30 CST 2015]; root of context hierarchy INFO:2015-05-01 14:12:31[Thread-2] - HHH000030: Cleaning up connection pool [jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE]
2、错误原因
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
Java中加了注解,但是在applicationContext.xml未配置事务管理
3、解决办法
在applicationContext.xml中添加事务管理配置
<!-- 事务管理 --> <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean>
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager'的更多相关文章
- 解决org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cacheManager' is defined
在Spring配置文件中加入了支持注解,即<mvc:annotation-driven/> 重新启动服务器包 org.springframework.beans.factory.NoSuc ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testService' is defined
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testService' is defi ...
- 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成to ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ExtractAbstractServiceHandler' is defined
在利用 Spring 集成 thrift 时,报错如下: javax.servlet.ServletException: Servlet.init() for servlet search-nlp-s ...
- cxf之org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' available
原因是.... 把cxf的配置文件spring-cxf-rest.xml配置结束后,没有import到spring.xml中...所以才加载不到bean.... 另附:异常org.springfram ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
spring-session 集成redis,web.xml配置filter时候出现 No bean named 'springSessionRepositoryFilter' is defined ...
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined
请检查你在web.xml中加载spring.xml文件的时候没有加载成功,看你的路径是否正确 <context-param> <param-name>contextConfi ...
- Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException
今天在学习spring 框架的时候看着,很简单.但是在真正开始做的时候发现,异常一个接着一个,整的肚子都被搞大了. Exception in thread "main" org.s ...
- 添加事务后 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type available
今天遇到了一个奇怪的问题 在没添加事务之前 所有的代码都是好的 , 当我添加了事务之后, 代码报错 org.springframework.beans.factory.NoSuchBeanDef ...
随机推荐
- json模块和pickle模块的用法
在python中,可以使用pickle和json两个模块对数据进行序列化操作 其中: json可以用于字符串或者字典等与python数据类型之间的序列化与反序列化操作 pickle可以用于python ...
- virtualbox创建虚拟机及增加硬盘记录
创建虚拟机 jken01VBoxManage createvm --name "jken01" --basefolder /data/virtualDir/jken01 --reg ...
- mvn mybatis-generator:generate postgresql
postgresql 配置文件 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE genera ...
- FreeMarker template error: The following has evaluated to null or missing: ==> blogger.md [in template "admin/about.ftl" at line 44, column 84]
FreeMarker template error:The following has evaluated to null or missing:==> blogger.md [in templ ...
- dlib下训练自己的物体检测器--手的检测
之前我们在Linux上安装了dlib(http://www.cnblogs.com/take-fetter/p/8318602.html),也成功的完成了之前的人脸检测程序, 今天我们来一起学习怎样使 ...
- codechef Dynamic GCD [树链剖分 gcd]
Dynamic GCD 题意:一棵树,字词树链加,树链gcd 根据\(gcd(a,b)=gcd(a,a-b)\) 得到\(gcd(a_1, a_2, ..., a_i) = gcd(a_1, a_1- ...
- BZOJ 2694: Lcm [莫比乌斯反演 线性筛]
题意:求\(\sum\limits_{i=1}^n \sum\limits_{j=1}^m lcm(i,j)\ : gcd(i,j) 是sf 无平方因子数\) 无平方因子数?搞一个\(\mu(gcd( ...
- POJ Christmas Game [树上删边游戏 Multi-SG]
传送门 题意: 有N 个局部联通的图.Harry 和Sally 轮流从图中删边,删去一条边后,不与根节点相连的部分将被移走.Sally 为先手.图是通过从基础树中加一些边得到的.所有形成的环保证不共用 ...
- C#查询XML解决“需要命名空间管理器”问题
在查询xml时有时会遇到带有前缀的xml,例如:"<ows:Keyword></ows:Keyword>" 这时像往常一样查询就会报错,类似于"需 ...
- Python中Template使用的一个小技巧
Python中Template是string中的一个类,可以将字符串的格式固定下来,重复利用. from string import Template s = Template("there ...