From d2d18b8de922517f7b1001c25448f373d094deec Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Thu, 2 Apr 2020 09:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20spring=20boot=20x=20seata?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab52/seatademo/controller/OrderController.java | 2 +- .../service/{PayService.java => AccountService.java} | 4 ++-- .../{PayServiceImpl.java => AmountServiceImpl.java} | 4 ++-- .../lab52/seatademo/service/impl/OrderServiceImpl.java | 4 ++-- .../src/main/resources/application.yaml | 10 ++-------- 5 files changed, 9 insertions(+), 15 deletions(-) rename lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/{PayService.java => AccountService.java} (85%) rename lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/{PayServiceImpl.java => AmountServiceImpl.java} (93%) diff --git a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/controller/OrderController.java b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/controller/OrderController.java index 3cb75882d..0d0a3b8dc 100644 --- a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/controller/OrderController.java +++ b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/controller/OrderController.java @@ -22,7 +22,7 @@ public class OrderController { public Integer createOrder(@RequestParam("userId") Long userId, @RequestParam("productId") Long productId, @RequestParam("price") Integer price) throws Exception { - logger.info("收到下单请求,用户:{}, 商品:{}, 价格:{}", userId, productId, price); + logger.info("[createOrder] 收到下单请求,用户:{}, 商品:{}, 价格:{}", userId, productId, price); return orderService.createOrder(userId, productId, price); } diff --git a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/PayService.java b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/AccountService.java similarity index 85% rename from lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/PayService.java rename to lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/AccountService.java index 6581867e4..74c762e7e 100644 --- a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/PayService.java +++ b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/AccountService.java @@ -1,9 +1,9 @@ package cn.iocoder.springboot.lab52.seatademo.service; /** - * 支付 Service + * 账户 Service */ -public interface PayService { +public interface AccountService { /** * 扣除余额 diff --git a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/PayServiceImpl.java b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/AmountServiceImpl.java similarity index 93% rename from lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/PayServiceImpl.java rename to lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/AmountServiceImpl.java index 9206487b6..5e8bfda4b 100644 --- a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/PayServiceImpl.java +++ b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/AmountServiceImpl.java @@ -1,7 +1,7 @@ package cn.iocoder.springboot.lab52.seatademo.service.impl; import cn.iocoder.springboot.lab52.seatademo.dao.AccountDao; -import cn.iocoder.springboot.lab52.seatademo.service.PayService; +import cn.iocoder.springboot.lab52.seatademo.service.AccountService; import com.baomidou.dynamic.datasource.annotation.DS; import io.seata.core.context.RootContext; import org.slf4j.Logger; @@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.Transactional; @Service -public class PayServiceImpl implements PayService { +public class AmountServiceImpl implements AccountService { private Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/OrderServiceImpl.java b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/OrderServiceImpl.java index 8ef74528e..f8db0b82b 100644 --- a/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/OrderServiceImpl.java +++ b/lab-52/lab-52-multiple-datasource/src/main/java/cn/iocoder/springboot/lab52/seatademo/service/impl/OrderServiceImpl.java @@ -3,7 +3,7 @@ import cn.iocoder.springboot.lab52.seatademo.dao.OrderDao; import cn.iocoder.springboot.lab52.seatademo.entity.OrderDO; import cn.iocoder.springboot.lab52.seatademo.service.OrderService; -import cn.iocoder.springboot.lab52.seatademo.service.PayService; +import cn.iocoder.springboot.lab52.seatademo.service.AccountService; import cn.iocoder.springboot.lab52.seatademo.service.StorageService; import com.baomidou.dynamic.datasource.annotation.DS; import io.seata.core.context.RootContext; @@ -22,7 +22,7 @@ public class OrderServiceImpl implements OrderService { private OrderDao orderDao; @Autowired - private PayService payService; + private AccountService payService; @Autowired private StorageService storageService; diff --git a/lab-52/lab-52-multiple-datasource/src/main/resources/application.yaml b/lab-52/lab-52-multiple-datasource/src/main/resources/application.yaml index e0b7d35da..0a0773d6f 100644 --- a/lab-52/lab-52-multiple-datasource/src/main/resources/application.yaml +++ b/lab-52/lab-52-multiple-datasource/src/main/resources/application.yaml @@ -5,12 +5,6 @@ spring: application: name: multi-datasource-service # 应用名 -# cloud: -# alibaba: -# # Seata 配置项,对应 SpringCloudAlibabaConfiguration 类 -# seata: -# tx-service-group: my_test_tx_group - datasource: # dynamic-datasource-spring-boot-starter 动态数据源的配配项,对应 DynamicDataSourceProperties 类 dynamic: @@ -22,8 +16,8 @@ spring: driver-class-name: com.mysql.jdbc.Driver username: root password: - # 支付 pay 数据源配置 - pay-ds: + # 账户 pay 数据源配置 + amount-ds: url: jdbc:mysql://127.0.0.1:3306/seata_pay?useSSL=false&useUnicode=true&characterEncoding=UTF-8 driver-class-name: com.mysql.jdbc.Driver username: root