当前位置: 首页 > 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

相关文章:

  • 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?
  • 中美经贸高层会谈在瑞士日内瓦举行
  • 我国成功发射遥感四十号02组卫星
  • “春申阡陌”漆画展:将传统漆艺融入现代创作
  • 要更加冷静地看待“东升西降”的判断
  • 华泰柏瑞基金总经理韩勇因工作调整卸任,董事长贾波代为履职
  • 国家发改委:美芯片药品等领域关税影响全球科技发展,损害人类共同利益