spring - bean 'org.springframework.transaction.config.internalTransactionAdvisor' 已经注册
问题描述
我已经定义了一个简单的 SpringBoot Hibernate 应用程序,它是从 Internet 上随机站点中找到的示例代码复制粘贴而来的。我希望相关的部分spring.xml
看起来像这样:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
... details ommitted ...
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
... details ommitted ...
<bean id="transactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
为什么我会收到此错误?
无法注册在类路径资源 [org/springframework/transaction/annotation/ProxyTransactionManagementConfiguration.class] 中定义的 bean 'org.springframework.transaction.config.internalTransactionAdvisor'。已在 null 中定义了具有该名称的 bean,并且禁用了覆盖。
我已经尝试过的其他事情
- 使用
org.springframework.jdbc.datasource.DataSourceTransactionManager
- 相同的错误 - 使用
org.springframework.orm.jpa.JpaTransactionManager
- 相同的错误 - 删除
transactionManager
bean - 好的,我的 SpringBoot 应用程序可以工作,但现在我所有的 JUnit 测试都中断了
解决方案
推荐阅读
- python-3.x - PyCharm:致命的 Python 错误:init_fs_encoding: failed to get the Python codec of the filesystem encoding
- postgresql - pg_advisory_lock 在 typeorm 中是如何工作的?
- arrays - 如何在 JSX 中同时映射对象数据或两个数组
- shell - 在 shell 脚本中传递参数以及从 CSV 文件中获取数据
- discord.py - Discord.py 机器人,未在所需位置创建类别
- android - 使用 ProviderTestCase2 测试内容提供者
- button - HTML5 按钮颜色
- python - 网页抓取 Youtube 页面
- google-cloud-firestore - 文档读取计数 Firestore 中的子集合吗?
- python - Django 和 Pycharm 社区版 Doctype html Unexpected Token