From a43beb44a67266c19b9ab6635a636fc8778b3371 Mon Sep 17 00:00:00 2001 From: pengten <30648785+pengten@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:23:43 +0800 Subject: [PATCH] bugfix: fix the exception with SeataTCCFenceAutoConfiguration (#4515) --- changes/en-us/develop.md | 7 ++++--- changes/zh-cn/develop.md | 6 ++++-- .../boot/autoconfigure/SeataTCCFenceAutoConfiguration.java | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md index 5b094264494..29251c3f7bc 100644 --- a/changes/en-us/develop.md +++ b/changes/en-us/develop.md @@ -7,10 +7,11 @@ Add changes here for all PR submitted to the develop branch. ### bugfix: -- [[#4661](https://github.com/seata/seata/pull/4661)] Fix sql exception with PostgreSQL in module console + - [[#4515](https://github.com/seata/seata/pull/4515)] fix the error of SeataTCCFenceAutoConfiguration when database unused + - [[#4661](https://github.com/seata/seata/pull/4661)] fix sql exception with PostgreSQL in module console ### optimize: -- [[#4650](https://github.com/seata/seata/pull/4650)] fix some security vulnerabilities + - [[#4650](https://github.com/seata/seata/pull/4650)] fix some security vulnerabilities ### test: @@ -18,7 +19,7 @@ Thanks to these contributors for their code commits. Please report an unintended - [slievrly](https://github.com/slievrly) +- [pengten](https://github.com/pengten) - [YSF-A](https://github.com/YSF-A) - Also, we receive many valuable issues, questions and advices from our community. Thanks for you all. diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md index 0487f5d4def..6a5b3e9f33e 100644 --- a/changes/zh-cn/develop.md +++ b/changes/zh-cn/develop.md @@ -5,10 +5,11 @@ ### feature: ### bugfix: -- [[#4661](https://github.com/seata/seata/pull/4661)] 修复控制台中使用PostgreSQL出现的SQL异常 + - [[#4515](https://github.com/seata/seata/pull/4515)] 修复develop分支SeataTCCFenceAutoConfiguration在客户端未使用DB时,启动抛出ClassNotFoundException的问题。 + - [[#4661](https://github.com/seata/seata/pull/4661)] 修复控制台中使用PostgreSQL出现的SQL异常 ### optimize: -- [[#4650](https://github.com/seata/seata/pull/4650)] 修复安全漏洞 + - [[#4650](https://github.com/seata/seata/pull/4650)] 修复安全漏洞 ### test: @@ -17,6 +18,7 @@ - [slievrly](https://github.com/slievrly) +- [pengten](https://github.com/pengten) - [YSF-A](https://github.com/YSF-A) 同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 \ No newline at end of file diff --git a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/main/java/io/seata/spring/boot/autoconfigure/SeataTCCFenceAutoConfiguration.java b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/main/java/io/seata/spring/boot/autoconfigure/SeataTCCFenceAutoConfiguration.java index 5cded37b81e..3f4cd97a87f 100644 --- a/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/main/java/io/seata/spring/boot/autoconfigure/SeataTCCFenceAutoConfiguration.java +++ b/seata-spring-autoconfigure/seata-spring-autoconfigure-client/src/main/java/io/seata/spring/boot/autoconfigure/SeataTCCFenceAutoConfiguration.java @@ -36,6 +36,8 @@ * @author kaka2code */ @ConditionalOnExpression("${seata.enabled:true}") +@ConditionalOnBean(type = {"javax.sql.DataSource", "org.springframework.transaction.PlatformTransactionManager"}) +@ConditionalOnMissingBean(TCCFenceConfig.class) @AutoConfigureAfter({SeataCoreAutoConfiguration.class, DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class}) public class SeataTCCFenceAutoConfiguration { @@ -43,8 +45,6 @@ public class SeataTCCFenceAutoConfiguration { public static final String TCC_FENCE_TRANSACTION_MANAGER_BEAN_NAME = "seataTCCFenceTransactionManager"; @Bean - @ConditionalOnMissingBean(TCCFenceConfig.class) - @ConditionalOnBean({DataSource.class, PlatformTransactionManager.class}) @ConfigurationProperties(StarterConstants.TCC_FENCE_PREFIX) public TCCFenceConfig tccFenceConfig( DataSource dataSource,