chore(config): 更新服务器端口配置从8082到18082

- 修改application-dev.yml和application-prod.yml中的server.port配置
- 更新PayPal webhook URL中的端口号
- 修改DEPLOYMENT_README.md中的端口引用信息
- 更新ProductServiceImpl.java中的端口配置注入
- 创建PORT_CHANGE_GUIDE.md提供端口修改操作指南
- 更新部署文档中的防火墙端口和Nginx配置说明
This commit is contained in:
2025-12-26 13:43:26 +08:00
parent 2d9a9c3668
commit 56ae5a5892
6 changed files with 192 additions and 12 deletions

View File

@@ -6,8 +6,8 @@
1. **配置文件已更新**
-`app.frontend.url` 已设置为 `http://175.178.252.59:3000`
-`paypal.webhook-url` 已设置为 `http://175.178.252.59:8082/api/paypal/webhook`
- ✅ 前端 `.env.production` 已创建API地址为 `http://175.178.252.59:8082/api`
-`paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
- ✅ 前端 `.env.production` 已创建API地址为 `/api`(相对路径)
2. **打包应用**
```bash
@@ -44,8 +44,8 @@
3. **API地址配置**
- ✅ `.env.production` 文件已创建
- ✅ API地址已设置为 `http://175.178.252.59:8082/api`
- 如果没有该文件,构建时会使用默认值 `/api`(相对路径)
- ✅ API地址已设置为 `/api`相对路径通过Nginx代理
- ⚠️ **重要:** 必须使用相对路径 `/api`不要使用完整URL
4. **上传到服务器**
```bash
@@ -62,10 +62,11 @@
部署前请检查以下配置:
- [x] 后端 `app.frontend.url` 已设置为 `http://175.178.252.59:3000`
- [x] 后端 `paypal.webhook-url` 已设置为 `http://175.178.252.59:8082/api/paypal/webhook`
- [x] 前端API地址已配置为 `http://175.178.252.59:8082/api`
- [x] 后端 `paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
- [x] 前端API地址已配置为 `/api`相对路径通过Nginx代理
- [ ] 数据库连接信息正确
- [ ] 服务器防火墙已开放必要端口8082、3000等
- [ ] PayPal控制台Webhook URL已更新为 `http://175.178.252.59:8082/api/paypal/webhook`
- [ ] 服务器防火墙已开放必要端口(18082、3000等
- [ ] PayPal控制台Webhook URL已更新为 `http://175.178.252.59:18082/api/paypal/webhook`
- [ ] **Nginx配置中的proxy_pass端口已更新为18082**

116
PORT_CHANGE_GUIDE.md Normal file
View File

@@ -0,0 +1,116 @@
# 端口修改指南8082 → 18082
## ✅ 已完成的代码修改
以下文件已自动修改:
1. **后端配置文件**
- `mt-pay/src/main/resources/application-dev.yml`: `server.port: 18082`
- `mt-pay/src/main/resources/application-prod.yml`: `server.port: ${server.port:18082}`
- `application-dev.yml`: `paypal.webhook-url: http://175.178.252.59:18082/api/paypal/webhook`
2. **Java代码**
- `ProductServiceImpl.java`: `@Value("${server.port:18082}")`
3. **前端配置**
- `vite.config.js`: 开发环境代理端口改为 `18082`
4. **部署文档**
- `DEPLOYMENT_README.md`: 所有端口引用已更新
## ⚠️ 需要手动操作
### 1. 重新打包后端
```bash
cd E:\MTKJPAY
mvn clean package -DskipTests
```
### 2. 在宝塔中修改Nginx配置
**重要:** 必须修改Nginx配置文件中的 `proxy_pass` 端口!
找到Nginx配置文件通常在宝塔面板 → 网站 → 设置 → 配置文件),修改:
**修改前:**
```nginx
location /api/ {
proxy_pass http://127.0.0.1:8082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
**修改后:**
```nginx
location /api/ {
proxy_pass http://127.0.0.1:18082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
修改后,在宝塔面板中:
1. 点击"保存"
2. 点击"重载配置"或"重启Nginx"
### 3. 更新PayPal Webhook URL如果已配置
如果已经在PayPal控制台配置了Webhook需要更新URL
- 旧URL: `http://175.178.252.59:8082/api/paypal/webhook`
- 新URL: `http://175.178.252.59:18082/api/paypal/webhook`
### 4. 检查防火墙
确保服务器防火墙已开放新端口 `18082`
- 宝塔面板 → 安全 → 添加端口规则:`18082`
### 5. 上传并启动新的jar包
```bash
# 上传新的jar包到服务器
# 停止旧进程(如果正在运行)
# 启动新进程
java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
# 或后台运行
nohup java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev > app.log 2>&1 &
```
## 验证
1. **检查后端是否启动成功**
```bash
# 在服务器上执行
netstat -tlnp | grep 18082
# 或
curl http://127.0.0.1:18082/api/health
```
2. **检查Nginx代理是否正常**
```bash
# 在服务器上执行
curl http://127.0.0.1/api/health
```
3. **浏览器测试**
- 访问前端页面
- 打开浏览器控制台F12
- 检查Network标签中的API请求
- 应该能正常访问 `/api/xxx` 接口
## 总结
**必须完成的操作:**
1. ✅ 代码已修改(已完成)
2. ⚠️ **重新打包后端**(必须)
3. ⚠️ **修改Nginx配置**(必须)
4. ⚠️ **上传新jar包并重启**(必须)
5. ⚠️ **更新PayPal Webhook URL**(如果已配置)
6. ⚠️ **开放防火墙端口**(必须)
**注意:** 只修改代码是不够的必须重新打包并修改Nginx配置

View File

@@ -682,3 +682,66 @@ Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No q
- 图片上传接口: http://localhost:8082//api/product/upload/image
- 商品管理接口: http://localhost:8082//api/product
2025-12-26 10:54:12.470 [Thread-36] INFO org.apache.coyote.http11.Http11NioProtocol - Stopping ProtocolHandler ["http-nio-8082"]
2025-12-26 10:54:12.518 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ MTKJ PAY 支付系统正在启动... ║
║ ║
╚══════════════════════════════════════════════════════════╝
2025-12-26 10:54:12.550 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Starting MtkjpayApplication using Java 17.0.12 with PID 23252 (E:\MTKJPAY\mt-startup\target\classes started by 18969 in E:\MTKJPAY)
2025-12-26 10:54:12.550 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - The following 1 profile is active: "dev"
2025-12-26 10:54:12.825 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8082"]
2025-12-26 10:54:12.826 [restartedMain] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
2025-12-26 10:54:12.826 [restartedMain] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.16]
2025-12-26 10:54:12.856 [restartedMain] INFO o.a.c.c.ContainerBase.[Tomcat-1].[localhost].[/] - Initializing Spring embedded WebApplicationContext
2025-12-26 10:54:12.864 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - ═══════════════════════════════════════════════════════════
2025-12-26 10:54:12.864 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - PayPal配置加载验证:
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Client ID: ✅ 已配置 (AdGYUZpvLuHR30dybOAp...)
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Client Secret: ✅ 已配置 (ENblspyRmwsOU_PWFurl...)
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Mode: sandbox
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Enabled: true
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Base URL: https://api-m.sandbox.paypal.com
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Webhook URL: ✅ https://2646b437.r33.cpolar.top/api/paypal/webhook
2025-12-26 10:54:12.865 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - ═══════════════════════════════════════════════════════════
2025-12-26 10:54:12.870 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - 初始化MyBatis-Plus分页插件数据库类型: MYSQL
2025-12-26 10:54:12.870 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - MyBatis-Plus分页插件配置完成
2025-12-26 10:54:12.873 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 初始化Druid主数据源
2025-12-26 10:54:12.873 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 配置属性 - URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai, Username: mtkj2025
2025-12-26 10:54:12.873 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - Druid主数据源配置完成URL: jdbc:mysql://rm-j6c3u06k2afwn8hxw6o.mysql.rds.aliyuncs.com:3306/mtpay?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
2025-12-26 10:54:13.187 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - 初始化RestClient配置JSON消息转换器
2025-12-26 10:54:13.189 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - RestClient配置完成
2025-12-26 10:54:13.194 [restartedMain] INFO com.mtkj.mtpay.config.AsyncConfig - PayPal Webhook异步处理线程池初始化完成
2025-12-26 10:54:13.217 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 配置跨域访问,路径: /api/**, 允许来源: *
2025-12-26 10:54:13.217 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 跨域配置完成
2025-12-26 10:54:13.287 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8082"]
2025-12-26 10:54:13.292 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Started MtkjpayApplication in 0.769 seconds (process running for 1374.992)
2025-12-26 10:54:13.294 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
╔══════════════════════════════════════════════════════════╗
║ ║
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
║ ║
╠══════════════════════════════════════════════════════════╣
║ 应用信息 ║
╠══════════════════════════════════════════════════════════╣
║ 应用名称: {:<45} ║
║ 运行环境: {:<45} ║
║ 服务端口: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 访问地址 ║
╠══════════════════════════════════════════════════════════╣
║ 后端服务: {:<45} ║
║ API接口: {:<45} ║
║ Druid监控: {:<45} ║
╠══════════════════════════════════════════════════════════╣
║ 状态: 🟢 服务运行中,可以接收请求 ║
╚══════════════════════════════════════════════════════════╝
2025-12-26 10:54:13.294 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
📌 提示:
- 前端代理地址: http://localhost:3000
- 后端API地址: http://localhost:8082//api
- 图片上传接口: http://localhost:8082//api/product/upload/image
- 商品管理接口: http://localhost:8082//api/product

View File

@@ -63,7 +63,7 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private BaiduTranslatorUtils baiduTranslatorUtils;
@Value("${server.port:8082}")
@Value("${server.port:18082}")
private String serverPort;
@Value("${server.servlet.context-path:}")

View File

@@ -63,7 +63,7 @@ spring:
# 服务器配置(所有环境通用)
server:
port: 8082
port: 18082
servlet:
context-path: /
# 文件上传配置
@@ -113,7 +113,7 @@ paypal:
enabled: true
# Webhook URL服务器公网地址
# 注意需要在PayPal控制台配置此URL
webhook-url: http://175.178.252.59:8082/api/paypal/webhook
webhook-url: http://175.178.252.59:18082/api/paypal/webhook
# Webhook ID从PayPal控制台获取用于验证Webhook签名
webhook-id: 0SX6117212808615P

View File

@@ -62,7 +62,7 @@ spring:
# 服务器配置
server:
port: ${server.port:8082}
port: ${server.port:18082}
servlet:
context-path: /
multipart: