无论您是多年编程的高级工程师,还是刚刚入门的实习生,部署请完全参考本文档操作,减少踩坑弯
① 项目下载
git clone https://gitee.com/log4j/pig.git
② 配置本地hosts
:::warning
必须配置 hosts ,禁止修改代码中配置成IP | 梯子、VPN 等软件会导致 hosts 配置失效,请关闭!!
如何快速修改本地hosts windows.zip mac.zip
:::
127.0.0.1 pig-mysql
127.0.0.1 pig-redis
127.0.0.1 pig-gateway
127.0.0.1 pig-register
127.0.0.1 pig-sentinel
127.0.0.1 pig-monitor
127.0.0.1 pig-job
127.0.0.1 pig-seata
③ 初始化数据库
- 版本: mysql5.7.8+
- 默认字符集: utf8mb4
- 默认排序规则: utf8mb4_general_ci
核心数据库: pig/db/pig.sql
nacos配置: pig/db/pig_config.sql
代码生成脚本: pig/db/pig_codegen.sql
④ 配置文件修改
:::warning 特别说明: host配置不要改成IP :::
数据库源信息修改
pig/pig-register/src/main/resources/application.yml
db:
num: 1
user: ${MYSQL-USER:root} #修改:用户名
password: ${MYSQL-PWD:root} #修改:密码, 特殊字符使用 '包裹'
url:
0: jdbc:mysql://${MYSQL-HOST:pig-mysql}:${MYSQL-PORT:3306}/${MYSQL-DB:pig_config}?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true
Redis、MySQL 配置
访问: http://pig-register:8848/nacos (默认账号密码 nacos/nacos)
- application-dev.yml
# redis 相关,无密码为空即可,不要修改成IP,修改hosts
spring:
redis:
password:
- 数据库密码配置,修改以下几个文件
pig-upms-biz.yml
pig-codegen-dev.yml
# 数据源,只需要修改密码即可,不要修改成IP,修改hosts
spring:
datasource:
username: root
password: lengleng
⑤ 启动顺序
- 找到对应模块的类,直接右键Main 启动即可 ```java
- pig-register/PigNacosApplication.java
- pig-auth/PigAuthApplication.java
- pig-upms-biz/PigAdminApplication
- pig-gateway/PigGatewayApplication.java
```
- 使用代码生成、监控时再启动以下项目
5. pig-codegen/PigCodeGenApplication
6. pig-monitor/PigMonitorApplication
7. pig-sentinel-dashboard/PigSentinelApplication
8. pig-xxl-job-admin/PigXxlJobAdminApplication