# mmall **Repository Path**: xu_bin_mayun/mmall ## Basic Information - **Project Name**: mmall - **Description**: 技术栈 dubbo、nacos、zookeeper、seata、mysql、redis、mybatis、mybatis-plus。商城项目 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2022-05-31 - **Last Updated**: 2022-05-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # mmall #### 技术栈 - dubbo - spring boot - zookeeper - seata - mysql - redis - mybatis - mybatis-plus - nacos - jwt - Leaf #### 软件架构 Software architecture description #### 安装教程 1. 安装 [nacos 1.1.0](https://github.com/alibaba/nacos/releases/tag/1.1.0), nacos [使用说明](https://nacos.io/zh-cn/docs/quick-start.html) 2. 安装配置 zookeeper 3. 安装配置 mysql 4. 安装配置 redis 5. 安装 seata #### 使用说明 - 采用的美团开源的 Leaft 来做分布式 ID 生成,原理参考文章 [Leaf——美团点评分布式ID生成系统](https://tech.meituan.com/2017/04/21/mt-leaf.html) - 采用的 JWT 来做的用户登录访问权限验证,参考文章 [jjwt](https://github.com/jwtk/jjwt) - 采用的 seata 来解决分布式事务问题,主要使用的是它默认的策略,辅助可以使用对应的 TCC 策略,参考文章 [seata 文档](http://seata.io/zh-cn/docs/overview/what_is_seata.html) - 采用的 nacos 来作为 dubbo 服务注册中心,参考文章 [nacos 文档](https://nacos.io/zh-cn/docs/quick-start.html) - 采用的 zookeeper 来作为 seata 的注册中心(也可以使用 nacos 而不引入 zookeeper) - 采用的 ShardingSphere 来作为分库分表使用框架,参考文章 [shading 文档](https://shardingsphere.apache.org/document/current/cn/overview/) - spring boot、dubbo、mybatis 应该都比较熟悉就不多做介绍了 - 同时存在 redis 集群 - 存在 mysql 集群每个微服务模块都存在多个数据库,不同的数据路由到不同的数据库存储 ##### 配置 mysql ``` create database mall charset uft8; source user_ddl.sql; source ${seata_home}/conf/db_store.sql; source ${seata_home}/conf/db_undo_log.sql; // 注意会抛错可以手动复制 SQL 执行 ``` `db_store.sql` 和 `db_undo_log.sql` 这两个文件再 seata 目录下的 conf 文件夹中 ##### 配置 seata 主要是修改 `${seata_home}/conf/ 下的 file.conf & registry.conf` 这两个文件 修改 `file.conf` 如下内容 ``` store { ## store mode: file、db mode = "db" # 修改处,指定为 db 后 file 处失效 ## file store file { dir = "sessionStore" # 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 # async, sync flush-disk-mode = async } ## database store 修改用户名和密码等 db { ## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp) etc. datasource = "druid" # 此处必须修改 seata 事务的混滚依赖 datasource 且必须和项目保存一致 ## mysql/oracle/h2/oceanbase etc. db-type = "mysql" driver-class-name = "com.mysql.jdbc.Driver" url = "jdbc:mysql://127.0.0.1:3306/seata" # 修改此处 user = "root" # 修改此处 password = "123456" # 修改此处 min-conn = 1 max-conn = 3 global.table = "global_table" branch.table = "branch_table" lock-table = "lock_table" query-limit = 100 } } ``` 修改 registry.conf,此处修改主要注册用心可以选用任意的注册中心,使用 zk 或者 nocas 等都可以 ``` registry { type= "zk" } ``` # token userId: 1187267594248257609 eyJhbGciOiJIUzUxMiJ9.eyJpYXQiOjE1NzE5MDM2NzIsImlzcyI6IjExODcyNjc1OTQyNDgyNTc2MDkiLCJleHAiOjE1NzIwODM2NzJ9.TA_LW4PEqEhLp56T1R4mpoSntF4Zk1juKG9f80Wy_jLZQ1vWlpOSMHiCRuCAt0AIMAsOVPDe4zEROTbaRQwfnA