diff --git a/pay/pay-service-impl/pom.xml b/pay/pay-service-impl/pom.xml index 65aedbc29..409c79377 100644 --- a/pay/pay-service-impl/pom.xml +++ b/pay/pay-service-impl/pom.xml @@ -54,23 +54,22 @@ mybatis-plus-boot-starter - - io.seata - seata-spring - - - io.seata - seata-dubbo - - - org.apache.dubbo - dubbo + com.alibaba.cloud + spring-cloud-starter-dubbo + + - org.apache.dubbo - dubbo-spring-boot-starter + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-alibaba-seata @@ -99,16 +98,6 @@ jar - - - org.apache.curator - curator-framework - - - org.apache.curator - curator-recipes - - org.springframework.boot @@ -143,4 +132,5 @@ http://jcenter.bintray.com + diff --git a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/DatabaseConfiguration.java b/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/DatabaseConfiguration.java index c8636d211..73abd7faa 100644 --- a/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/DatabaseConfiguration.java +++ b/pay/pay-service-impl/src/main/java/cn/iocoder/mall/pay/biz/config/DatabaseConfiguration.java @@ -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); - } - } diff --git a/pay/pay-service-impl/src/main/resources/config/application-test.yaml b/pay/pay-service-impl/src/main/resources/config/application-test.yaml index de4b20659..b8ff14095 100644 --- a/pay/pay-service-impl/src/main/resources/config/application-test.yaml +++ b/pay/pay-service-impl/src/main/resources/config/application-test.yaml @@ -1,11 +1,3 @@ -spring: - # datasource - datasource: - url: jdbc:mysql://192.168.88.14:3306/mall_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8 - driver-class-name: com.mysql.jdbc.Driver - username: root - password: ${MALL_MYSQL_PASSWORD} - # xxl-job xxl: job: @@ -18,9 +10,3 @@ xxl: logpath: /Users/yunai/logs/xxl-job/ logretentiondays: 1 accessToken: - -# rocketmq -rocketmq: - name-server: 192.168.88.14:9876 - producer: - group: pay-producer-group diff --git a/pay/pay-service-impl/src/main/resources/config/application.yaml b/pay/pay-service-impl/src/main/resources/config/application.yaml index c32231710..78543d4c3 100644 --- a/pay/pay-service-impl/src/main/resources/config/application.yaml +++ b/pay/pay-service-impl/src/main/resources/config/application.yaml @@ -6,21 +6,31 @@ spring: username: root password: ${MALL_MYSQL_PASSWORD} + # Spring Cloud 配置项 + cloud: + nacos: + # Spring Cloud Nacos Discovery 配置项 + discovery: + server-addr: 127.0.0.1:8848 # Nacos 服务器地址 + # mybatis mybatis-plus: config-location: classpath:mybatis-config.xml mapper-locations: classpath:mapper/*.xml type-aliases-package: cn.iocoder.mall.pay.biz.dataobject -# dubbo +# Dubbo 配置项 dubbo: - application: - name: pay-service + # Dubbo 注册中心 registry: - address: zookeeper://127.0.0.1:2181 + address: spring-cloud://127.0.0.1:8848 # 指定 Dubbo 服务注册中心的地址 + # Spring Cloud Alibaba Dubbo 专属配置 + cloud: + subscribed-services: admin-application # 设置订阅的应用列表,默认为 * 订阅所有应用 + # Dubbo 提供者的协议 protocol: - port: -1 name: dubbo + port: -1 scan: base-packages: cn.iocoder.mall.pay.biz.service provider: @@ -36,6 +46,12 @@ rocketmq: producer: group: pay-producer-group -# seata +# Seata 配置项 seata: - tx-service-group: my_test_tx_group + # Seata 注册中心配置项 + registry: + type: nacos # 注册中心类型 + nacos: + serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址 + namespace: # Nacos 命名空间 + cluster: default # 使用的 Seata 分组 diff --git a/pay/pay-service-impl/src/main/resources/file.conf b/pay/pay-service-impl/src/main/resources/file.conf deleted file mode 100644 index 8b60b29c3..000000000 --- a/pay/pay-service-impl/src/main/resources/file.conf +++ /dev/null @@ -1,69 +0,0 @@ -transport { - # tcp udt unix-domain-socket - type = "TCP" - #NIO NATIVE - server = "NIO" - #enable heartbeat - heartbeat = true - #thread factory for netty - thread-factory { - boss-thread-prefix = "NettyBoss" - worker-thread-prefix = "NettyServerNIOWorker" - server-executor-thread-prefix = "NettyServerBizHandler" - share-boss-worker = false - client-selector-thread-prefix = "NettyClientSelector" - client-selector-thread-size = 1 - client-worker-thread-prefix = "NettyClientWorkerThread" - # netty boss thread size,will not be used for UDT - boss-thread-size = 1 - #auto default pin or 8 - worker-thread-size = 8 - } -} - -service { - #vgroup->rgroup - vgroup_mapping.my_test_tx_group = "default" - #only support single node - default.grouplist = "180.167.213.26:8091" - #degrade current not support - enableDegrade = false - #disable - disable = false -} - -client { - async.commit.buffer.limit = 10000 - lock { - retry.internal = 10 - retry.times = 30 - } -} -## transaction log store -store { - ## store mode: file、db - mode = "file" - - ## file store - file { - dir = "file_store/data" - - # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions - max-branch-session-size = 16384 - # globe session size , if exceeded throws exceptions - max-global-session-size = 512 - # file buffer size , if exceeded allocate new buffer - file-write-buffer-cache-size = 16384 - # when recover batch read size - session.reload.read_size = 100 - } - - ## database store - db { - driver_class = "" - url = "" - user = "" - password = "" - } -} - diff --git a/pay/pay-service-impl/src/main/resources/registry.conf b/pay/pay-service-impl/src/main/resources/registry.conf deleted file mode 100644 index f73989514..000000000 --- a/pay/pay-service-impl/src/main/resources/registry.conf +++ /dev/null @@ -1,14 +0,0 @@ -registry { - type = "file" - - file { - name = "file.conf" - } - - zk { - cluster = "default" - serverAddr = "192.168.88.10:2181" - session.timeout = 6000 - connect.timeout = 2000 - } -} diff --git a/pay/pom.xml b/pay/pom.xml index d0fe8f9f1..89320ffc4 100644 --- a/pay/pom.xml +++ b/pay/pom.xml @@ -17,5 +17,16 @@ pay-service-impl + + + + cn.iocoder.mall + common-dependencies + 1.0-SNAPSHOT + pom + import + + + - \ No newline at end of file + diff --git a/product/product-service-impl/src/main/resources/config/application.yaml b/product/product-service-impl/src/main/resources/config/application.yaml index 0b9ae2a58..2e46540cc 100644 --- a/product/product-service-impl/src/main/resources/config/application.yaml +++ b/product/product-service-impl/src/main/resources/config/application.yaml @@ -26,7 +26,7 @@ dubbo: address: spring-cloud://127.0.0.1:8848 # 指定 Dubbo 服务注册中心的地址 # Spring Cloud Alibaba Dubbo 专属配置 cloud: - subscribed-services: 'admin-application' # 设置订阅的应用列表,默认为 * 订阅所有应用 + subscribed-services: admin-application # 设置订阅的应用列表,默认为 * 订阅所有应用 # Dubbo 提供者的协议 protocol: name: dubbo @@ -62,6 +62,6 @@ seata: registry: type: nacos # 注册中心类型 nacos: - serverAddr: 127.0.0.1:8848 # Nacos 服务地址 + serverAddr: ${spring.cloud.nacos.discovery.server-addr} # Nacos 服务地址 namespace: # Nacos 命名空间 cluster: default # 使用的 Seata 分组