Merge remote-tracking branch 'origin/master'

This commit is contained in:
sin 2019-05-14 19:20:01 +08:00
commit 2187ae2662
17 changed files with 210 additions and 179 deletions

View File

@ -113,22 +113,25 @@ TODO 此处应有一个架构图的装逼 JPG 图。
| --- | --- | --- | | --- | --- | --- |
| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.1.4 | | [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.1.4 |
| [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.6 | | [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 数据库 | 暂未引入,等压测后,部分模块 | | [Redis](https://redis.io/) | key-value 数据库 | 暂未引入,等压测后,部分模块 |
| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 暂未引入,等压测后,部分模块 | | [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 暂未引入,等压测后,部分模块 |
| [Elasticsearch](https://www.elastic.co/cn/) | 分布式搜索引擎 | 6.7.1 | | [Elasticsearch](https://www.elastic.co/cn/) | 分布式搜索引擎 | 6.7.1 |
| [Dubbo](http://dubbo.apache.org/) | 分布式 RPC 服务框架 | 2.7.1 | | [Dubbo](http://dubbo.apache.org/) | 分布式 RPC 服务框架 | 2.7.1 |
| [RocketMQ](http://dubbo.apache.org/) | 消息中间件 | 4.3.2 | | [RocketMQ](http://dubbo.apache.org/) | 消息中间件 | 4.3.2 |
| [SkyWalking](http://skywalking.apache.org/) | 分布式应用追踪系统 | 6.0.0 | | [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 作为注册中心 | | [Zookeeper](http://zookeeper.apache.org/) | 分布式系统协调 | 3.4.9 作为注册中心 |
| [XXL-Job](http://www.xuxueli.com/xxl-job/) | 分布式任务调度平台 | 2.0.1 | | [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 * [ ] 配置中心 Nacos
* [ ] 服务保障 Sentinel * [ ] 服务保障 Sentinel
* [ ] 分布式事务 Seata
* [ ] 数据库连接池 Druid
* [ ] 网关 Soul * [ ] 网关 Soul
### 前端 ### 前端

View File

@ -0,0 +1,6 @@
swagger:
enable: true
title: 订单子系统
description: 订单子系统
version: 1.0.0
base-package: cn.iocoder.mall.pay.application.controller

View File

@ -9,7 +9,4 @@ server:
context-path: /order-api/ context-path: /order-api/
swagger: swagger:
title: 订单子系统 enable: false
description: 订单子系统
version: 1.0.0
base-package: cn.iocoder.mall.pay.application.controller

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 使用驼峰命名法转换字段。 -->
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
<typeAliases>
<typeAlias alias="Integer" type="java.lang.Integer"/>
<typeAlias alias="Long" type="java.lang.Long"/>
<typeAlias alias="HashMap" type="java.util.HashMap"/>
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap"/>
<typeAlias alias="ArrayList" type="java.util.ArrayList"/>
<typeAlias alias="LinkedList" type="java.util.LinkedList"/>
</typeAliases>
</configuration>

View File

@ -1,15 +1,15 @@
package cn.iocoder.mall.order.biz.config; package cn.iocoder.mall.order.biz.config;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import io.seata.rm.datasource.DataSourceProxy; import io.seata.rm.datasource.DataSourceProxy;
import io.seata.spring.annotation.GlobalTransactionScanner; import io.seata.spring.annotation.GlobalTransactionScanner;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.transaction.annotation.EnableTransactionManagement; 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 @EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理为什么使用 proxyTargetClass 参数参见 https://blog.csdn.net/huang_550/article/details/76492600
public class DatabaseConfiguration { public class DatabaseConfiguration {
// 数据源使用 HikariCP
@Value("${spring.application.name}") @Value("${spring.application.name}")
private String applicationId; private String applicationId;
@Value("${seata.tx-service-group}")
private String txServiceGroup;
@Autowired @Bean("druidDataSource")
private DataSourceProperties dataSourceProperties; @ConfigurationProperties("spring.datasource.druid")
@Bean
// @Primary
public DruidDataSource druidDataSource(){ public DruidDataSource druidDataSource(){
DruidDataSource druidDataSource = new DruidDataSource(); return DruidDataSourceBuilder.create().build();
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;
} }
@ConfigurationProperties(prefix = "spring.datasource") @ConfigurationProperties(prefix = "spring.datasource")
@Primary @Primary
@Bean("dataSource") @Bean("dataSource")
// @Bean @DependsOn("druidDataSource") // 解决多数据源循环依赖的问题主要发生点在 DataSourceInitializerInvoker
public DataSource dataSource(DruidDataSource dataSource) { public DataSource dataSource() {
return new DataSourceProxy(dataSource); DruidDataSource druidDataSource = druidDataSource();
return new DataSourceProxy(druidDataSource);
} }
/**
* 注册一个StatViewServlet
*
* @return global transaction scanner
*/
@Bean @Bean
public GlobalTransactionScanner globalTransactionScanner() { public GlobalTransactionScanner globalTransactionScanner() {
return new GlobalTransactionScanner(applicationId, "my_test_tx_group"); return new GlobalTransactionScanner(applicationId, txServiceGroup);
// TODO 芋艿txServiceGroup 后续要编辑下
} }
} }

View File

@ -1,9 +0,0 @@
package cn.iocoder.mall.order.biz.config;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SeataConfiguration {
}

View File

@ -59,3 +59,7 @@ logging:
level: level:
# dao 开启 debug 模式 mybatis 输入 sql # dao 开启 debug 模式 mybatis 输入 sql
cn.iocoder.mall.order.biz.dao: debug cn.iocoder.mall.order.biz.dao: debug
# seata
seata:
tx-service-group: my_test_tx_group

View File

@ -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 = ""
}
}

View File

@ -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
}
}

View File

@ -12,6 +12,7 @@
<artifactId>promotion-application</artifactId> <artifactId>promotion-application</artifactId>
<dependencies> <dependencies>
<!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId> <artifactId>common-framework</artifactId>
@ -53,15 +54,12 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<!-- Web 相关 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
@ -72,6 +70,13 @@
<artifactId>swagger-bootstrap-ui</artifactId> <artifactId>swagger-bootstrap-ui</artifactId>
</dependency> </dependency>
<!-- 测试相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -0,0 +1,6 @@
swagger:
enable: false
title: 营销子系统
description: 营销子系统
version: 1.0.0
base-package: cn.iocoder.mall.promotion.application.controller

View File

@ -9,7 +9,4 @@ server:
context-path: /promotion-api/ context-path: /promotion-api/
swagger: swagger:
title: 营销子系统 enable: false
description: 营销子系统
version: 1.0.0
base-package: cn.iocoder.mall.promotion.application.controller

View File

@ -12,17 +12,14 @@
<artifactId>promotion-service-api</artifactId> <artifactId>promotion-service-api</artifactId>
<dependencies> <dependencies>
<!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>common-framework</artifactId> <artifactId>common-framework</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <!-- 工具类相关 -->
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.mapstruct</groupId> <groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher --> <artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
@ -31,6 +28,7 @@
<groupId>org.mapstruct</groupId> <groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId> <artifactId>mapstruct-jdk8</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>

View File

@ -12,6 +12,7 @@
<artifactId>promotion-service-impl</artifactId> <artifactId>promotion-service-impl</artifactId>
<dependencies> <dependencies>
<!-- Mall 相关 -->
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>promotion-service-api</artifactId> <artifactId>promotion-service-api</artifactId>
@ -28,92 +29,12 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <!-- DB 相关 -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-jdbc</artifactId>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>logback-classic</artifactId>-->
<!-- <groupId>ch.qos.logback</groupId>-->
<!-- </exclusion>-->
<!-- <exclusion>-->
<!-- <artifactId>spring-boot-starter-logging</artifactId>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring</artifactId>
</dependency>
<!--dependency for Apache Dubbo-->
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-dubbo</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-discovery-zk</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId> <artifactId>spring-tx</artifactId>
@ -122,12 +43,70 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId> <artifactId>spring-jdbc</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>--> <dependency>
<!-- <artifactId>spring-tx</artifactId>--> <groupId>com.alibaba</groupId>
<!-- <version>5.0.12.RELEASE</version>--> <artifactId>druid-spring-boot-starter</artifactId>
<!-- <scope>compile</scope>--> </dependency>
<!-- </dependency>-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring</artifactId>
</dependency>
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-dubbo</artifactId>
</dependency>
<!-- RPC 相关 -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>
<!-- Registry 和 Config 相关 -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</dependency>
<!-- MQ 相关 -->
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
</dependency>
<!-- Job 相关 -->
<dependency>
<groupId>com.xuxueli</groupId>
<artifactId>xxl-job-core</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<!-- 测试相关 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,6 @@
swagger:
enable: true
title: 搜索子系统
description: 搜索子系统
version: 1.0.0
base-package: cn.iocoder.mall.search.application.controller

View File

@ -9,7 +9,4 @@ server:
context-path: /search-api/ context-path: /search-api/
swagger: swagger:
title: 搜索子系统 enable: false
description: 搜索子系统
version: 1.0.0
base-package: cn.iocoder.mall.search.application.controller

View File

@ -18,6 +18,11 @@
<artifactId>search-service-api</artifactId> <artifactId>search-service-api</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.mall</groupId>
<artifactId>mall-spring-boot</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>cn.iocoder.mall</groupId> <groupId>cn.iocoder.mall</groupId>
<artifactId>product-service-api</artifactId> <artifactId>product-service-api</artifactId>