当前位置: 首页 > news >正文

0.环境初始化

容器化部署

Nginx

  • 前端文件在 html\hmdp 下,挂载到 /usr/share/nginx/html 下

    • 所以要求 nginx.conf :

    • root /usr/share/nginx/html;

    • index index.html;

    • 反向代理:proxy_pass http://host.docker.internal:8081;

    • listen 80; 因为容器内端口为80

    • 因为 Nginx 监听 80 端口,且 Docker 映射了 80→80,所以访问 http://localhost(80 端口)就能看到页面d

  • 对应的logs,nginx.conf 也挂载

docker run -d `--name dianping_nginx `-p 80:80 `-v E:\Projects\03.DianPing\Client\nginx_dianping\conf\nginx.conf:/etc/nginx/nginx.conf `-v E:\Projects\03.DianPing\Client\nginx_dianping\html\hmdp:/usr/share/nginx/html `-v E:\Projects\03.DianPing\Client\nginx_dianping\logs:/var/log/nginx `nginx:latest

worker_processes  1;events {worker_connections  1024;
}http {include       mime.types;default_type  application/json;sendfile        on;keepalive_timeout  65;# docker run -d `# >>   --name dianping-nginx `# >>   -p 80:80 `# >>   -v E:\Projects\03.DianPing\Client\nginx_dianping\conf\nginx.conf:/etc/nginx/nginx.conf `# >>   -v E:\Projects\03.DianPing\Client\nginx_dianping\html\hmdp:/usr/share/nginx/html `# >>   -v E:\Projects\03.DianPing\Client\nginx_dianping\logs:/var/log/nginx `# >>   nginx:latestserver {listen       80;server_name  localhost;# 指定前端项目所在的位置location / {# root   html/hmdp;  #本机root   /usr/share/nginx/html;  #dockerindex  index.html;}error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}location /api {  default_type  application/json;#internal;  keepalive_timeout   30s;  keepalive_requests  1000;  #支持keep-alive  proxy_http_version 1.1;  rewrite /api(/.*) $1 break;  proxy_pass_request_headers on;#more_clear_input_headers Accept-Encoding;  proxy_next_upstream error timeout;  proxy_set_header Host host.docker.internal;  # 强制指定目标主机proxy_set_header X-Forwarded-Host $host;     # 保留原始请求的 Host# proxy_pass http://127.0.0.1:8081;proxy_pass http://host.docker.internal:8081; # docker 部署#proxy_pass http://backend;}}upstream backend {server 127.0.0.1:8081 max_fails=5 fail_timeout=10s weight=1;#server 127.0.0.1:8082 max_fails=5 fail_timeout=10s weight=1;}  
}

MySQL

  1. 创建容器
docker run -d -p 3306:3306 --privileged=true -v E:\Projects\03.DianPing\mysql\log:/var/log/mysql -v E:\Projects\03.D
ianPing\mysql\data:/var/lib/mysql -v E:\Projects\03.DianPing\mysql\conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 --name dian
ping_mysql mysql:8.0.25
  • 解决乱码
[client]
default-character-set = utf8mb4[mysqld]
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci[mysql]
default-character-set = utf8mb4

在Navicat中执行:

SHOW VARIABLES LIKE 'character%';

Redis

docker run -d --name dianping_redis -p 6379:6379 --privileged=true -v E:\Projects\03.DianPing\redis\redis.conf:/etc/redis/redis.conf -v E:\Projects\03.DianPing\redis\data:/data redis
appendonly yes
bind 0.0.0.0
protected-mode no

框架阅读

config

  • MybatisPlusInterceptor

    • 加载了mybatisplus的分页插件
  • WebExceptionAdvice

    • @ExceptionHandler(RuntimeException.class),简单的全局异常处理

Controller

http://www.dtcms.com/a/183478.html

相关文章:

  • Python时间模块
  • PXE_Kickstart_无人值守自动化安装系统
  • 自动语音拨号系统V2.6.0产品说明书
  • BC12-字符金字塔
  • day21python打卡
  • HC-SR04超声波测距传感器
  • Block Styler——字符串控件
  • jetson orin nano super AI模型部署之路(十)使用frp配置内网穿透,随时随地ssh到机器
  • 含锡电镀废水深度净化技术体系解析化利用的全流程优化
  • 【C++贪心 位运算】B3930 烹饪问题|普及
  • Day20打卡-奇异值SVD分解
  • 2025年大模型RAG技术的实践总结
  • 解释器和基于规则的系统比较
  • 历史数据分析——北部湾港
  • (2025)图文解锁RAG从原理到实操
  • 当冲压焊接遇上Canopen到Profinet协议转换网关
  • 【XCP实战】AUTOSAR架构下XCP DAQ功能配置实现
  • 代码随想录算法训练营第三十七天
  • 学习黑客5 分钟深入浅出理解Linux Logs [特殊字符]
  • MD5 值是什么?为什么文件需要检验 MD5?
  • 手机银行怎么打印流水账单(已解决)
  • LintCode第485题-生成给定大小的数组,第220题-冰雹猜想,第235题-分解质因数
  • 便签软件哪个好用?2025年桌面记事本便签软件推荐大全
  • ProfiNet转MODBUS模块构建西门子PLC与RTU仪表通讯连接方案
  • 考研408《计算机组成原理》复习笔记,第三章数值数据的表示和运算(定点数篇)
  • CMake 入门实践
  • jflash下载时出现 Could not read unit serial number! 的解决方法
  • SierraNet M1288网络损伤功能显著助力GPU互联网络的测试验证,包含包喷洒,LLR等复杂特性的验证测试
  • Python中的事件循环是什么?事件是怎么个事件?循环是怎么个循环
  • 【C++】string类(一)构造、重载、容量操作、访问与遍历(迭代器、范围for)、练习