forked from YunaiV/yudao-cloud
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
将 pay 模块接入 SCA Dubbo 和 Nacos Discovery 组件,同时将 Seata 修改成 SCA Seata 组件
- Loading branch information
Showing
8 changed files
with
48 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/DatabaseConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,12 @@ | ||
package cn.iocoder.mall.pay.biz.config; | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; | ||
import io.seata.rm.datasource.DataSourceProxy; | ||
import io.seata.spring.annotation.GlobalTransactionScanner; | ||
import org.mybatis.spring.annotation.MapperScan; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.DependsOn; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
import javax.sql.DataSource; | ||
|
||
@Configuration | ||
@MapperScan("cn.iocoder.mall.pay.biz.dao") // 扫描对应的 Mapper 接口 | ||
@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600 | ||
public class DatabaseConfiguration { | ||
|
||
@Value("${spring.application.name}") | ||
private String applicationId; | ||
@Value("${seata.tx-service-group}") | ||
private String txServiceGroup; | ||
|
||
@Bean("druidDataSource") | ||
@ConfigurationProperties("spring.datasource.druid") | ||
public DruidDataSource druidDataSource(){ | ||
return DruidDataSourceBuilder.create().build(); | ||
} | ||
|
||
@ConfigurationProperties(prefix = "spring.datasource") | ||
@Primary | ||
@Bean("dataSource") | ||
@DependsOn("druidDataSource") // 解决多数据源,循环依赖的问题。主要发生点在 DataSourceInitializerInvoker | ||
public DataSource dataSource() { | ||
DruidDataSource druidDataSource = druidDataSource(); | ||
return new DataSourceProxy(druidDataSource); | ||
} | ||
|
||
@Bean | ||
public GlobalTransactionScanner globalTransactionScanner() { | ||
return new GlobalTransactionScanner(applicationId, txServiceGroup); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters