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

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.xdnf.cn/news/5179.html

相关文章:

  • 基于Spring Boot + Vue的高校心理教育辅导系统
  • uniapp小程序中实现无缝衔接滚动效果
  • Mysql中in和exists的区别?
  • 神经网络极简入门技术分享
  • JavaScript基础-三元表达式
  • Nakama:让游戏与应用更具互动性和即时性
  • 用Python绘制动态彩色ASCII爱心:技术深度与创意结合
  • Ajax基础
  • ui组件二次封装(vue)
  • PyTorch API 7 - TorchScript、hub、矩阵、打包、profile
  • 互联网大厂Java求职面试:基于RAG的智能问答系统设计与实现-2
  • 如何删除网上下载的资源后面的文字
  • AI生成视频推荐
  • ragflow报错:KeyError: ‘\n “序号“‘
  • 【Linux学习笔记】系统文件IO之重定向原理分析
  • 第七章 数据库编程
  • 数据链共享:从印巴空战到工业控制的跨越性应用
  • 右值引用的剖析
  • 通俗易懂版知识点:Keepalived + LVS + Web + NFS 高可用集群到底是干什么的?
  • 【数据结构】——栈
  • C++中的static_cast:类型转换的安全卫士
  • VUE CLI - 使用VUE脚手架创建前端项目工程
  • 【Qwen3_ 4b lora xinli 】 task完成实践记录
  • 11.多用组合和少继承
  • 通俗易懂的方式解释“帧”和“报文”。帧和报文在不同网络层次中的作用。
  • Navicat 17最新保姆级安装教程(附安装包+永久使用方法)
  • R1-Omni
  • 纷析云开源财务软件:企业敏捷迭代的生态化赋能平台
  • Science | “打结”的光
  • NextDenovo2.5.2安装与使用-生信工具53