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'的更多相关文章

  1. 解决org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cacheManager' is defined

    在Spring配置文件中加入了支持注解,即<mvc:annotation-driven/> 重新启动服务器包 org.springframework.beans.factory.NoSuc ...

  2. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testService' is defined

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'testService' is defi ...

  3. 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined

    报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成to ...

  4. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'ExtractAbstractServiceHandler' is defined

    在利用 Spring 集成 thrift 时,报错如下: javax.servlet.ServletException: Servlet.init() for servlet search-nlp-s ...

  5. cxf之org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' available

    原因是.... 把cxf的配置文件spring-cxf-rest.xml配置结束后,没有import到spring.xml中...所以才加载不到bean.... 另附:异常org.springfram ...

  6. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined

    spring-session 集成redis,web.xml配置filter时候出现  No bean named 'springSessionRepositoryFilter' is defined ...

  7. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is defined

    请检查你在web.xml中加载spring.xml文件的时候没有加载成功,看你的路径是否正确 <context-param>  <param-name>contextConfi ...

  8. Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException

    今天在学习spring 框架的时候看着,很简单.但是在真正开始做的时候发现,异常一个接着一个,整的肚子都被搞大了. Exception in thread "main" org.s ...

  9. 添加事务后 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type available

    今天遇到了一个奇怪的问题   在没添加事务之前  所有的代码都是好的 , 当我添加了事务之后, 代码报错 org.springframework.beans.factory.NoSuchBeanDef ...

随机推荐

  1. bootstrap select2 使用简单介绍

    1. 基本属性配置: $("#select2-id").select2({ templateResult : formatState, // 列表带图片 templateSelec ...

  2. iOS-键盘监听YYKeyboardManager

    如果键盘弹出覆盖了原有的试图,这种效果并不好,所以我们就要在键盘弹出的时候,监听键盘的位置来改变我们一些试图的位置,例如tableView列表等:在这里推荐一个大牛ibireme写的YYKeyboar ...

  3. 使用hbase小结

    背景 hbase中一张表的rowkey定义为时间戳+字符串 需求 根据时间戳和列簇中某列的值为"abc",导出一天内的数据到excel中. 使用FilterList FilterL ...

  4. k短路模板 POJ2449

    采用A*算法的k短路模板 #include <iostream> #include <cstdio> #include <cstring> #include < ...

  5. 洛谷 [P1282] 多米诺骨牌

    这道题是一道背包问题,考虑一个背包, 显然如果我们直接设dp[i]表示前i个使差值最小所需的最少翻转次数,是具有后效性的. 所以我们将直接求最值,改为求某个值是否可行,这种求最值转变为求可行性的思想是 ...

  6. BZOJ 2809: [Apio2012]dispatching [主席树 DFS序]

    传送门 题意:查询树上根节点值*子树中权值和$\le m$的最大数量 最大值是多少 求$DFS$序,然后变成区间中和$\le m$最多有几个元素,建主席树,然后权值线段树上二分就行了 $WA$:又把边 ...

  7. C# ListBox 每行显示颜色设置

    使用ListBox时,每行显示不同的颜色 1.把AllowHtmlDraw属性设置为True 2.直接在Add或者AddRange里写标签 代码里用的是DEV插件里的ListBox,使用原生的也是一样 ...

  8. Go学习笔记02-源码

    第二部分 源码 基于 Go 1.4,相关文件位于 src/runtime 目录.文章忽略了 32bit 代码,有兴趣的可自行查看源码文件.为便于阅读,示例代码做过裁剪. 1. Memory Alloc ...

  9. Zabbix 3.0 监控Web

    zabbix 界面配置 触发器添加

  10. idea出现Error:Maven Resources Compiler: Maven project configuration required for module 'market' isn't available.

    idea出现如下错误解决办法 1.重新在Build-Rebuild project 既可以解决啦