From f77e5779550c44087e076eddae5780e02b64e6d7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 14 May 2019 00:02:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20promotion=20=E9=A1=B9=E7=9B=AE=EF=BC=8C=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E4=B8=8D=E5=BC=80=E5=90=AF=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20-=20=E5=90=8E=E7=AB=AF=EF=BC=9Apromotion=20?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=EF=BC=8C=E5=BC=95=E5=85=A5=20seata=20?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- promotion/promotion-application/pom.xml | 15 +- .../src/main/resources/application-test.yaml | 6 + .../src/main/resources/application.yaml | 5 +- promotion/promotion-service-api/pom.xml | 8 +- promotion/promotion-service-impl/pom.xml | 153 ++++++++---------- 5 files changed, 86 insertions(+), 101 deletions(-) create mode 100644 promotion/promotion-application/src/main/resources/application-test.yaml diff --git a/promotion/promotion-application/pom.xml b/promotion/promotion-application/pom.xml index a83040df4..f00b8e4be 100644 --- a/promotion/promotion-application/pom.xml +++ b/promotion/promotion-application/pom.xml @@ -12,6 +12,7 @@ promotion-application + cn.iocoder.mall common-framework @@ -53,15 +54,12 @@ 1.0-SNAPSHOT + org.springframework.boot spring-boot-starter-web - - org.springframework.boot - spring-boot-starter-test - test - + io.springfox @@ -72,6 +70,13 @@ swagger-bootstrap-ui + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/promotion/promotion-application/src/main/resources/application-test.yaml b/promotion/promotion-application/src/main/resources/application-test.yaml new file mode 100644 index 000000000..96b1b5566 --- /dev/null +++ b/promotion/promotion-application/src/main/resources/application-test.yaml @@ -0,0 +1,6 @@ +swagger: + enable: false + title: 营销子系统 + description: 营销子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.promotion.application.controller diff --git a/promotion/promotion-application/src/main/resources/application.yaml b/promotion/promotion-application/src/main/resources/application.yaml index e6d66102e..9d226a880 100644 --- a/promotion/promotion-application/src/main/resources/application.yaml +++ b/promotion/promotion-application/src/main/resources/application.yaml @@ -9,7 +9,4 @@ server: context-path: /promotion-api/ swagger: - title: 营销子系统 - description: 营销子系统 - version: 1.0.0 - base-package: cn.iocoder.mall.promotion.application.controller + enable: false diff --git a/promotion/promotion-service-api/pom.xml b/promotion/promotion-service-api/pom.xml index cfbce1019..e7f74dd1f 100644 --- a/promotion/promotion-service-api/pom.xml +++ b/promotion/promotion-service-api/pom.xml @@ -12,17 +12,14 @@ promotion-service-api + cn.iocoder.mall common-framework 1.0-SNAPSHOT - - javax.validation - validation-api - - + org.mapstruct mapstruct @@ -31,6 +28,7 @@ org.mapstruct mapstruct-jdk8 + org.projectlombok lombok diff --git a/promotion/promotion-service-impl/pom.xml b/promotion/promotion-service-impl/pom.xml index 9b6a5704b..1ce26638e 100644 --- a/promotion/promotion-service-impl/pom.xml +++ b/promotion/promotion-service-impl/pom.xml @@ -12,6 +12,7 @@ promotion-service-impl + cn.iocoder.mall promotion-service-api @@ -28,92 +29,12 @@ 1.0-SNAPSHOT - - com.google.guava - guava - - - com.xuxueli - xxl-job-core - - + mysql mysql-connector-java - - com.alibaba - druid-spring-boot-starter - - - - - - - - - - - - - - - - - - org.apache.dubbo - dubbo - - - org.apache.curator - curator-framework - - - org.apache.curator - curator-recipes - - - org.apache.dubbo - dubbo-spring-boot-starter - - - - com.baomidou - mybatis-plus-boot-starter - - - org.springframework.boot - spring-boot-starter-jdbc - - - - - - org.apache.rocketmq - rocketmq-spring-boot-starter - - - - io.seata - seata-spring - - - - io.seata - seata-dubbo - - - io.seata - seata-discovery-zk - - - - - org.springframework.boot - spring-boot-starter-test - test - org.springframework spring-tx @@ -122,12 +43,70 @@ org.springframework spring-jdbc - - - - - - + + + com.alibaba + druid-spring-boot-starter + + + + com.baomidou + mybatis-plus-boot-starter + + + + io.seata + seata-spring + + + io.seata + seata-dubbo + + + + + org.apache.dubbo + dubbo + + + org.apache.dubbo + dubbo-spring-boot-starter + + + + + org.apache.curator + curator-framework + + + org.apache.curator + curator-recipes + + + + + org.apache.rocketmq + rocketmq-spring-boot-starter + + + + + com.xuxueli + xxl-job-core + + + + + com.google.guava + guava + + + + + org.springframework.boot + spring-boot-starter-test + test + From 21e5fb954adbd2c1a800ded9bdd72a358d157df3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 14 May 2019 00:12:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20order=20=E9=A1=B9=E7=9B=AE=EF=BC=8C=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E4=B8=8D=E5=BC=80=E5=90=AF=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20-=20=E5=90=8E=E7=AB=AF=EF=BC=9Aorder=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E5=BC=95=E5=85=A5=20seata=20=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E4=BA=8B=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-test.yaml | 6 ++ .../src/main/resources/application.yaml | 5 +- .../src/main/resources/mybatis-config.xml | 19 ----- .../biz/config/DatabaseConfiguration.java | 51 ++++---------- .../order/biz/config/SeataConfiguration.java | 9 --- .../main/resources/config/application.yaml | 4 ++ .../src/main/resources/file.conf | 69 +++++++++++++++++++ .../src/main/resources/registry.conf | 14 ++++ 8 files changed, 106 insertions(+), 71 deletions(-) create mode 100644 order/order-application/src/main/resources/application-test.yaml delete mode 100644 order/order-application/src/main/resources/mybatis-config.xml delete mode 100644 order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/SeataConfiguration.java create mode 100644 order/order-service-impl/src/main/resources/file.conf create mode 100644 order/order-service-impl/src/main/resources/registry.conf diff --git a/order/order-application/src/main/resources/application-test.yaml b/order/order-application/src/main/resources/application-test.yaml new file mode 100644 index 000000000..ff9f80fd8 --- /dev/null +++ b/order/order-application/src/main/resources/application-test.yaml @@ -0,0 +1,6 @@ +swagger: + enable: true + title: 订单子系统 + description: 订单子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.pay.application.controller diff --git a/order/order-application/src/main/resources/application.yaml b/order/order-application/src/main/resources/application.yaml index e9f9b609f..da8336365 100644 --- a/order/order-application/src/main/resources/application.yaml +++ b/order/order-application/src/main/resources/application.yaml @@ -9,7 +9,4 @@ server: context-path: /order-api/ swagger: - title: 订单子系统 - description: 订单子系统 - version: 1.0.0 - base-package: cn.iocoder.mall.pay.application.controller + enable: false diff --git a/order/order-application/src/main/resources/mybatis-config.xml b/order/order-application/src/main/resources/mybatis-config.xml deleted file mode 100644 index 7f604cc7e..000000000 --- a/order/order-application/src/main/resources/mybatis-config.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/DatabaseConfiguration.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/DatabaseConfiguration.java index e0da6e15a..ad7a667ab 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/DatabaseConfiguration.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/DatabaseConfiguration.java @@ -1,15 +1,15 @@ package cn.iocoder.mall.order.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.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; 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; @@ -20,56 +20,29 @@ import javax.sql.DataSource; @EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600 public class DatabaseConfiguration { - // 数据源,使用 HikariCP - @Value("${spring.application.name}") private String applicationId; + @Value("${seata.tx-service-group}") + private String txServiceGroup; - @Autowired - private DataSourceProperties dataSourceProperties; - - @Bean -// @Primary + @Bean("druidDataSource") + @ConfigurationProperties("spring.datasource.druid") public DruidDataSource druidDataSource(){ - DruidDataSource druidDataSource = new DruidDataSource(); - druidDataSource.setUrl(dataSourceProperties.getUrl()); - druidDataSource.setUsername(dataSourceProperties.getUsername()); - druidDataSource.setPassword(dataSourceProperties.getPassword()); - druidDataSource.setDriverClassName(dataSourceProperties.getDriverClassName()); - druidDataSource.setInitialSize(0); - druidDataSource.setMaxActive(180); - druidDataSource.setMaxWait(60000); - druidDataSource.setMinIdle(0); - druidDataSource.setValidationQuery("Select 1 from DUAL"); - druidDataSource.setTestOnBorrow(false); - druidDataSource.setTestOnReturn(false); - druidDataSource.setTestWhileIdle(true); - druidDataSource.setTimeBetweenEvictionRunsMillis(60000); - druidDataSource.setMinEvictableIdleTimeMillis(25200000); - druidDataSource.setRemoveAbandoned(true); - druidDataSource.setRemoveAbandonedTimeout(1800); - druidDataSource.setLogAbandoned(true); - return druidDataSource; + return DruidDataSourceBuilder.create().build(); } @ConfigurationProperties(prefix = "spring.datasource") @Primary @Bean("dataSource") -// @Bean - public DataSource dataSource(DruidDataSource dataSource) { - return new DataSourceProxy(dataSource); + @DependsOn("druidDataSource") // 解决多数据源,循环依赖的问题。主要发生点在 DataSourceInitializerInvoker + public DataSource dataSource() { + DruidDataSource druidDataSource = druidDataSource(); + return new DataSourceProxy(druidDataSource); } - /** - * 注册一个StatViewServlet - * - * @return global transaction scanner - */ @Bean public GlobalTransactionScanner globalTransactionScanner() { - return new GlobalTransactionScanner(applicationId, "my_test_tx_group"); - // TODO 芋艿,txServiceGroup 后续要编辑下 + return new GlobalTransactionScanner(applicationId, txServiceGroup); } - } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/SeataConfiguration.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/SeataConfiguration.java deleted file mode 100644 index ace05c0cf..000000000 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/config/SeataConfiguration.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.iocoder.mall.order.biz.config; - -import org.springframework.context.annotation.Configuration; - -@Configuration -public class SeataConfiguration { - - -} diff --git a/order/order-service-impl/src/main/resources/config/application.yaml b/order/order-service-impl/src/main/resources/config/application.yaml index 6cb9ee36e..a60232b1b 100644 --- a/order/order-service-impl/src/main/resources/config/application.yaml +++ b/order/order-service-impl/src/main/resources/config/application.yaml @@ -59,3 +59,7 @@ logging: level: # dao 开启 debug 模式 mybatis 输入 sql cn.iocoder.mall.order.biz.dao: debug + +# seata +seata: + tx-service-group: my_test_tx_group diff --git a/order/order-service-impl/src/main/resources/file.conf b/order/order-service-impl/src/main/resources/file.conf new file mode 100644 index 000000000..8b60b29c3 --- /dev/null +++ b/order/order-service-impl/src/main/resources/file.conf @@ -0,0 +1,69 @@ +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/order/order-service-impl/src/main/resources/registry.conf b/order/order-service-impl/src/main/resources/registry.conf new file mode 100644 index 000000000..f73989514 --- /dev/null +++ b/order/order-service-impl/src/main/resources/registry.conf @@ -0,0 +1,14 @@ +registry { + type = "file" + + file { + name = "file.conf" + } + + zk { + cluster = "default" + serverAddr = "192.168.88.10:2181" + session.timeout = 6000 + connect.timeout = 2000 + } +} From 7abdcbaed3975268abbd8820fc783940235536e1 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 14 May 2019 00:26:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?-=20=E5=90=8E=E7=AB=AF=EF=BC=9A=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20search=20=E9=A1=B9=E7=9B=AE=EF=BC=8C=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E4=B8=8D=E5=BC=80=E5=90=AF=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20-=20=E5=90=8E=E7=AB=AF=EF=BC=9Asearch=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=EF=BC=8C=E5=BC=95=E5=85=A5=20seata=20=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E4=BA=8B=E5=8A=A1=20-=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=20README=20=E6=96=87=E4=BB=B6=EF=BC=8C=E5=A2=9E=E5=8A=A0=20myb?= =?UTF-8?q?atis-plus=E3=80=81seata=E3=80=81swagger2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++--- .../src/main/resources/application-test.yaml | 6 ++++++ .../src/main/resources/application.yaml | 5 +---- search/search-service-impl/pom.xml | 5 +++++ 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 search/search-application/src/main/resources/application-test.yaml diff --git a/README.md b/README.md index 85d5d4a88..324329dd9 100644 --- a/README.md +++ b/README.md @@ -113,22 +113,25 @@ TODO 此处应有一个架构图的装逼 JPG 图。 | --- | --- | --- | | [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.1.4 | | [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.6 | -| [MyBatis](http://www.mybatis.org/mybatis-3/zh/index.html) | 数据持久层框架 | 3.5.0 | +| [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.1.16 | +| [MyBatis](http://www.mybatis.org/mybatis-3/zh/index.html) | 数据持久层框架 | 3.5.1 | +| [MyBatis-Plus](https://mp.baomidou.com/) | Mybatis 增强工具包 | 3.1.1 | | [Redis](https://redis.io/) | key-value 数据库 | 暂未引入,等压测后,部分模块 | | [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 暂未引入,等压测后,部分模块 | | [Elasticsearch](https://www.elastic.co/cn/) | 分布式搜索引擎 | 6.7.1 | | [Dubbo](http://dubbo.apache.org/) | 分布式 RPC 服务框架 | 2.7.1 | | [RocketMQ](http://dubbo.apache.org/) | 消息中间件 | 4.3.2 | | [SkyWalking](http://skywalking.apache.org/) | 分布式应用追踪系统 | 6.0.0 | +| [Seata](https://github.com/seata/seata) | 分布式事务中间件 | 0.5.1 | | [Zookeeper](http://zookeeper.apache.org/) | 分布式系统协调 | 3.4.9 作为注册中心 | | [XXL-Job](http://www.xuxueli.com/xxl-job/) | 分布式任务调度平台 | 2.0.1 | +| [springfox-swagger2](https://github.com/springfox/springfox/tree/master/springfox-swagger2) | API 文档 | 2.9.2 | +| [swagger-bootstrap-ui](https://gitee.com/xiaoym/swagger-bootstrap-ui) | API 文档 | 1.9.3 | 未来考虑引入 * [ ] 配置中心 Nacos * [ ] 服务保障 Sentinel -* [ ] 分布式事务 Seata -* [ ] 数据库连接池 Druid * [ ] 网关 Soul ### 前端 diff --git a/search/search-application/src/main/resources/application-test.yaml b/search/search-application/src/main/resources/application-test.yaml new file mode 100644 index 000000000..e3581327f --- /dev/null +++ b/search/search-application/src/main/resources/application-test.yaml @@ -0,0 +1,6 @@ +swagger: + enable: true + title: 搜索子系统 + description: 搜索子系统 + version: 1.0.0 + base-package: cn.iocoder.mall.search.application.controller diff --git a/search/search-application/src/main/resources/application.yaml b/search/search-application/src/main/resources/application.yaml index 7d6ac2715..26de4509d 100644 --- a/search/search-application/src/main/resources/application.yaml +++ b/search/search-application/src/main/resources/application.yaml @@ -9,7 +9,4 @@ server: context-path: /search-api/ swagger: - title: 搜索子系统 - description: 搜索子系统 - version: 1.0.0 - base-package: cn.iocoder.mall.search.application.controller + enable: false diff --git a/search/search-service-impl/pom.xml b/search/search-service-impl/pom.xml index 4feb27695..c428d048f 100644 --- a/search/search-service-impl/pom.xml +++ b/search/search-service-impl/pom.xml @@ -18,6 +18,11 @@ search-service-api 1.0-SNAPSHOT + + cn.iocoder.mall + mall-spring-boot + 1.0-SNAPSHOT + cn.iocoder.mall product-service-api