Compare commits
4 Commits
bbf235362c
...
dev-qiubin
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a59f5c888 | |||
| 504ccabba1 | |||
| 07dcd9408c | |||
| a3633577b4 |
@@ -1,220 +0,0 @@
|
||||
# 502 Bad Gateway 错误排查指南
|
||||
|
||||
## 错误说明
|
||||
|
||||
`502 Bad Gateway` 表示 Nginx 无法连接到后端服务。通常是因为:
|
||||
1. **后端服务未启动**
|
||||
2. **Nginx配置中的端口不正确**(最常见)
|
||||
3. **后端服务启动失败**
|
||||
4. **防火墙阻止连接**
|
||||
|
||||
## 排查步骤
|
||||
|
||||
### 1. 检查后端服务是否启动
|
||||
|
||||
在服务器上执行:
|
||||
|
||||
```bash
|
||||
# 检查18082端口是否在监听
|
||||
netstat -tlnp | grep 18082
|
||||
# 或
|
||||
ss -tlnp | grep 18082
|
||||
|
||||
# 检查Java进程
|
||||
ps aux | grep java
|
||||
# 或
|
||||
jps -l
|
||||
```
|
||||
|
||||
**如果端口没有监听:**
|
||||
- 后端服务没有启动
|
||||
- 需要启动后端服务
|
||||
|
||||
### 2. 检查Nginx配置(最重要)
|
||||
|
||||
在宝塔面板中:
|
||||
1. 网站 → 设置 → 配置文件
|
||||
2. 找到 `location /api/` 配置块
|
||||
3. **确认 `proxy_pass` 端口是 `18082`**
|
||||
|
||||
**正确的配置:**
|
||||
```nginx
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:18082; # ← 必须是18082,不是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;
|
||||
}
|
||||
```
|
||||
|
||||
**错误的配置(会导致502):**
|
||||
```nginx
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:8082; # ← 错误:端口还是8082
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**修改后必须:**
|
||||
1. 点击"保存"
|
||||
2. 点击"重载配置"或"重启Nginx"
|
||||
|
||||
### 3. 测试后端服务是否正常
|
||||
|
||||
在服务器上执行:
|
||||
|
||||
```bash
|
||||
# 测试后端API是否可访问
|
||||
curl http://127.0.0.1:18082/api/health
|
||||
# 或
|
||||
curl http://127.0.0.1:18082/api/erp/user/login -X POST -H "Content-Type: application/json" -d '{"username":"test","password":"test"}'
|
||||
```
|
||||
|
||||
**如果返回连接拒绝:**
|
||||
- 后端服务没有启动
|
||||
- 检查启动日志
|
||||
|
||||
**如果返回正常响应:**
|
||||
- 后端服务正常
|
||||
- 问题在Nginx配置
|
||||
|
||||
### 4. 检查后端启动日志
|
||||
|
||||
查看后端启动日志,确认:
|
||||
- 服务是否成功启动
|
||||
- 是否监听在 `18082` 端口
|
||||
- 是否有错误信息
|
||||
|
||||
```bash
|
||||
# 如果使用nohup启动
|
||||
tail -f app.log
|
||||
|
||||
# 或查看Spring Boot启动日志
|
||||
# 应该看到类似信息:
|
||||
# Tomcat started on port(s): 18082 (http)
|
||||
```
|
||||
|
||||
### 5. 检查防火墙
|
||||
|
||||
在宝塔面板中:
|
||||
1. 安全 → 防火墙
|
||||
2. 确认端口 `18082` 已开放(如果后端需要外部访问)
|
||||
3. **注意:** 如果后端只监听 `127.0.0.1`,不需要开放防火墙
|
||||
|
||||
### 6. 检查后端监听地址
|
||||
|
||||
确认后端配置:
|
||||
|
||||
**application-dev.yml:**
|
||||
```yaml
|
||||
server:
|
||||
port: 18082
|
||||
# 如果没有配置 address,默认监听 0.0.0.0(所有网卡)
|
||||
# 如果配置了 address: 127.0.0.1,只监听本地
|
||||
```
|
||||
|
||||
**如果后端只监听 127.0.0.1:**
|
||||
- Nginx的 `proxy_pass` 必须使用 `http://127.0.0.1:18082`
|
||||
- 不能使用 `http://175.178.252.59:18082`
|
||||
|
||||
## 快速修复步骤
|
||||
|
||||
### 步骤1:确认后端服务已启动
|
||||
|
||||
```bash
|
||||
# 在服务器上执行
|
||||
java -jar mt-startup-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
|
||||
|
||||
# 或后台运行
|
||||
nohup java -jar mt-startup-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev > app.log 2>&1 &
|
||||
```
|
||||
|
||||
### 步骤2:修改Nginx配置
|
||||
|
||||
在宝塔面板中修改配置文件:
|
||||
|
||||
```nginx
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:18082; # 确保是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;
|
||||
# 添加超时配置(可选)
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
```
|
||||
|
||||
### 步骤3:重载Nginx
|
||||
|
||||
在宝塔面板中:
|
||||
1. 保存配置
|
||||
2. 重载配置
|
||||
|
||||
### 步骤4:验证
|
||||
|
||||
```bash
|
||||
# 在服务器上测试
|
||||
curl http://127.0.0.1/api/erp/user/login -X POST -H "Content-Type: application/json" -d '{"username":"test","password":"test"}'
|
||||
```
|
||||
|
||||
## 常见问题
|
||||
|
||||
### Q1: 修改了Nginx配置,但还是502?
|
||||
|
||||
**A:** 检查是否:
|
||||
- 保存了配置
|
||||
- 重载了Nginx(不是只保存)
|
||||
- 确认端口是 `18082`,不是 `8082`
|
||||
|
||||
### Q2: 后端服务启动了,但Nginx还是502?
|
||||
|
||||
**A:** 检查:
|
||||
- Nginx配置中的端口是否正确
|
||||
- 后端是否真的在 `18082` 端口监听
|
||||
- Nginx错误日志:`/www/wwwlogs/175.178.252.59.error.log`
|
||||
|
||||
### Q3: 如何查看Nginx错误日志?
|
||||
|
||||
**A:** 在宝塔面板中:
|
||||
- 网站 → 日志 → 错误日志
|
||||
- 或直接查看:`/www/wwwlogs/175.178.252.59.error.log`
|
||||
|
||||
查看是否有类似错误:
|
||||
```
|
||||
connect() failed (111: Connection refused) while connecting to upstream
|
||||
```
|
||||
这表示无法连接到后端。
|
||||
|
||||
## 验证清单
|
||||
|
||||
- [ ] 后端服务已启动
|
||||
- [ ] 后端监听在 `18082` 端口
|
||||
- [ ] Nginx配置中 `proxy_pass` 端口是 `18082`
|
||||
- [ ] Nginx配置已保存并重载
|
||||
- [ ] 防火墙已开放(如果需要)
|
||||
- [ ] 后端启动日志无错误
|
||||
|
||||
## 如果还是无法解决
|
||||
|
||||
1. **查看Nginx错误日志**
|
||||
```bash
|
||||
tail -f /www/wwwlogs/175.178.252.59.error.log
|
||||
```
|
||||
|
||||
2. **查看后端启动日志**
|
||||
```bash
|
||||
tail -f app.log
|
||||
```
|
||||
|
||||
3. **检查端口占用**
|
||||
```bash
|
||||
netstat -tlnp | grep 18082
|
||||
```
|
||||
|
||||
4. **测试后端直接访问**
|
||||
```bash
|
||||
curl http://127.0.0.1:18082/api/health
|
||||
```
|
||||
|
||||
@@ -4,25 +4,20 @@
|
||||
|
||||
### 后端部署
|
||||
|
||||
1. **配置文件已更新**
|
||||
- ✅ `app.frontend.url` 已设置为 `http://175.178.252.59:3000`
|
||||
- ✅ `paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
|
||||
- ✅ 前端 `.env.production` 已创建,API地址为 `/api`(相对路径)
|
||||
|
||||
2. **打包应用**
|
||||
1. **打包应用**
|
||||
```bash
|
||||
cd E:\MTKJPAY
|
||||
mvn clean package -DskipTests
|
||||
```
|
||||
|
||||
3. **上传并启动**
|
||||
2. **上传并启动**
|
||||
```bash
|
||||
# 上传 jar 文件到服务器
|
||||
# 启动应用
|
||||
java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
|
||||
# 启动应用(使用生产环境配置)
|
||||
java -jar mt-startup-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
|
||||
|
||||
# 或后台运行
|
||||
nohup java -jar mt-pay-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev > app.log 2>&1 &
|
||||
nohup java -jar mt-startup-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod > app.log 2>&1 &
|
||||
```
|
||||
|
||||
### 前端部署
|
||||
@@ -33,40 +28,20 @@
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. **本地测试打包结果(验证打包是否正确)**
|
||||
```bash
|
||||
cd dist
|
||||
python -m http.server 3000
|
||||
# 或
|
||||
npx http-server -p 3000
|
||||
# 访问 http://localhost:3000(应该能看到页面,不是空白)
|
||||
```
|
||||
|
||||
3. **API地址配置**
|
||||
- ✅ `.env.production` 文件已创建
|
||||
- ✅ API地址已设置为 `/api`(相对路径,通过Nginx代理)
|
||||
- ⚠️ **重要:** 必须使用相对路径 `/api`,不要使用完整URL
|
||||
|
||||
4. **上传到服务器**
|
||||
```bash
|
||||
# 上传dist目录下的所有文件到服务器
|
||||
scp -r dist/* root@175.178.252.59:/path/to/web/root/
|
||||
```
|
||||
|
||||
5. **服务器配置**
|
||||
- 如果服务器已有Web服务器,将dist内容放到Web根目录
|
||||
2. **上传到服务器**
|
||||
- 上传 `dist` 目录下的所有文件到服务器Web根目录
|
||||
- 确保支持Vue Router的history模式(配置 `try_files`)
|
||||
|
||||
## 配置说明
|
||||
|
||||
- **开发环境**:使用 `application-dev.yml`(本地开发,默认)
|
||||
- **生产环境**:使用 `application-prod.yml`(服务器部署,需指定 `--spring.profiles.active=prod`)
|
||||
|
||||
## 配置检查清单
|
||||
|
||||
部署前请检查以下配置:
|
||||
|
||||
- [x] 后端 `app.frontend.url` 已设置为 `http://175.178.252.59:3000`
|
||||
- [x] 后端 `paypal.webhook-url` 已设置为 `http://175.178.252.59:18082/api/paypal/webhook`
|
||||
- [x] 前端API地址已配置为 `/api`(相对路径,通过Nginx代理)
|
||||
- [ ] 数据库连接信息正确
|
||||
- [ ] 服务器防火墙已开放必要端口(18082、3000等)
|
||||
- [ ] PayPal控制台Webhook URL已更新为 `http://175.178.252.59:18082/api/paypal/webhook`
|
||||
- [ ] **Nginx配置中的proxy_pass端口已更新为18082**
|
||||
|
||||
|
||||
- [ ] 使用 `--spring.profiles.active=prod` 启动(生产环境配置)
|
||||
- [ ] 数据库连接信息正确(生产环境)
|
||||
- [ ] 服务器防火墙已开放必要端口(8082、443等)
|
||||
- [ ] Nginx已配置SSL证书(PayPal Webhook必需HTTPS)
|
||||
- [ ] Nginx配置中的proxy_pass端口为8082
|
||||
- [ ] PayPal控制台Webhook URL已配置为域名(HTTPS)
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# 项目改进计划
|
||||
|
||||
## 已完成功能
|
||||
|
||||
- ✅ 商品管理(创建、查询、下架、分页)
|
||||
- ✅ 订单管理(创建、查询、分页、状态管理)
|
||||
- ✅ PayPal支付集成(创建订单、捕获支付、Webhook处理)
|
||||
- ✅ 库存管理(扣减、恢复)
|
||||
- ✅ 货币转换(实时汇率、多币种支持)
|
||||
- ✅ ERP用户系统(注册、登录、信息管理)
|
||||
- ✅ 国际化支持(6种语言)
|
||||
|
||||
## 待实现功能(按优先级)
|
||||
|
||||
### 高优先级
|
||||
1. **商品编辑功能** - 支持修改商品信息
|
||||
2. **订单详情页面** - 显示完整订单和支付信息
|
||||
3. **订单状态管理** - 发货、完成、取消功能
|
||||
4. **密码加密升级** - MD5升级为BCrypt
|
||||
|
||||
### 中优先级
|
||||
5. **JWT Token实现** - 替换MD5+Base64 Token
|
||||
6. **Redis缓存集成** - PayPal token和汇率缓存
|
||||
7. **角色权限系统** - 角色和权限管理
|
||||
8. **操作日志系统** - 记录用户操作
|
||||
|
||||
### 低优先级
|
||||
9. **单元测试** - 测试覆盖率>70%
|
||||
10. **Swagger文档** - API文档自动生成
|
||||
11. **数据统计** - 销售和订单统计
|
||||
12. **容器化部署** - Docker支持
|
||||
|
||||
## 实施建议
|
||||
|
||||
**第一阶段(1-2周)**:商品编辑、订单详情、订单状态管理、密码加密升级
|
||||
|
||||
**第二阶段(2-3周)**:JWT Token、角色权限系统
|
||||
|
||||
**第三阶段(3-4周)**:Redis缓存、操作日志、性能优化
|
||||
26
logs/mt-pay-error.2025-12-26.log
Normal file
26
logs/mt-pay-error.2025-12-26.log
Normal file
@@ -0,0 +1,26 @@
|
||||
2025-12-26 15:45:27.906 [main] ERROR com.mtkj.mtkjpay.MtkjpayApplication -
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
|
||||
org.springframework.boot.devtools.restart.SilentExitExceptionHandler$SilentExitException: null
|
||||
at org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread(SilentExitExceptionHandler.java:92)
|
||||
at org.springframework.boot.devtools.restart.Restarter.immediateRestart(Restarter.java:179)
|
||||
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:163)
|
||||
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:532)
|
||||
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:98)
|
||||
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:51)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:178)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:171)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:149)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:137)
|
||||
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
|
||||
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:75)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.lambda$starting$0(SpringApplicationRunListeners.java:54)
|
||||
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:54)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
|
||||
at com.mtkj.mtkjpay.MtkjpayApplication.main(MtkjpayApplication.java:42)
|
||||
82
logs/mt-pay.2025-12-26.log
Normal file
82
logs/mt-pay.2025-12-26.log
Normal file
@@ -0,0 +1,82 @@
|
||||
2025-12-26 15:45:25.027 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 8.0.1.Final
|
||||
2025-12-26 15:45:25.071 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Starting MtkjpayApplication using Java 17.0.12 with PID 27200 (E:\MTKJPAY\mt-startup\target\classes started by 18969 in E:\MTKJPAY)
|
||||
2025-12-26 15:45:25.071 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - The following 1 profile is active: "dev"
|
||||
2025-12-26 15:45:26.484 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8082"]
|
||||
2025-12-26 15:45:26.485 [restartedMain] INFO org.apache.catalina.core.StandardService - Starting service [Tomcat]
|
||||
2025-12-26 15:45:26.485 [restartedMain] INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/10.1.16]
|
||||
2025-12-26 15:45:26.531 [restartedMain] INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
|
||||
2025-12-26 15:45:26.585 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - ═══════════════════════════════════════════════════════════
|
||||
2025-12-26 15:45:26.585 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - PayPal配置加载验证:
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Client ID: ✅ 已配置 (AdGYUZpvLuHR30dybOAp...)
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Client Secret: ✅ 已配置 (ENblspyRmwsOU_PWFurl...)
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Mode: sandbox
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Enabled: true
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Base URL: https://api-m.sandbox.paypal.com
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - - Webhook URL: ✅ https://2646b437.r33.cpolar.top/api/paypal/webhook
|
||||
2025-12-26 15:45:26.586 [restartedMain] INFO com.mtkj.mtpay.config.PayPalProperties - ═══════════════════════════════════════════════════════════
|
||||
2025-12-26 15:45:26.601 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - 初始化MyBatis-Plus分页插件,数据库类型: MYSQL
|
||||
2025-12-26 15:45:26.605 [restartedMain] INFO com.mtkj.mtpay.config.MyBatisPlusConfig - MyBatis-Plus分页插件配置完成
|
||||
2025-12-26 15:45:26.609 [restartedMain] INFO com.mtkj.mtpay.config.DruidDataSourceConfig - 初始化Druid主数据源
|
||||
2025-12-26 15:45:26.609 [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 15:45:26.661 [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 15:45:27.295 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - 初始化RestClient,配置JSON消息转换器
|
||||
2025-12-26 15:45:27.446 [restartedMain] INFO com.mtkj.mtpay.config.RestClientConfig - RestClient配置完成
|
||||
2025-12-26 15:45:27.452 [restartedMain] INFO com.mtkj.mtpay.config.AsyncConfig - PayPal Webhook异步处理线程池初始化完成
|
||||
2025-12-26 15:45:27.505 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 配置跨域访问,路径: /api/**, 允许来源: *
|
||||
2025-12-26 15:45:27.529 [restartedMain] INFO com.mtkj.mtpay.config.WebConfig - 跨域配置完成
|
||||
2025-12-26 15:45:27.881 [restartedMain] INFO org.apache.coyote.http11.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8082"]
|
||||
2025-12-26 15:45:27.898 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication - Started MtkjpayApplication in 3.497 seconds (process running for 5.039)
|
||||
2025-12-26 15:45:27.901 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
|
||||
║ ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用信息 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用名称: {:<45} ║
|
||||
║ 运行环境: {:<45} ║
|
||||
║ 服务端口: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 访问地址 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 后端服务: {:<45} ║
|
||||
║ API接口: {:<45} ║
|
||||
║ Druid监控: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 状态: 🟢 服务运行中,可以接收请求 ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
|
||||
2025-12-26 15:45:27.901 [restartedMain] INFO com.mtkj.mtkjpay.MtkjpayApplication -
|
||||
📌 提示:
|
||||
- 前端地址: https://shopd.mtkj2025.com
|
||||
- 后端API地址: https://shopd.mtkj2025.com:8082//api
|
||||
- 图片上传接口: https://shopd.mtkj2025.com:8082//api/product/upload/image
|
||||
- 商品管理接口: https://shopd.mtkj2025.com:8082//api/product
|
||||
|
||||
2025-12-26 15:45:27.906 [main] ERROR com.mtkj.mtkjpay.MtkjpayApplication -
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
|
||||
org.springframework.boot.devtools.restart.SilentExitExceptionHandler$SilentExitException: null
|
||||
at org.springframework.boot.devtools.restart.SilentExitExceptionHandler.exitCurrentThread(SilentExitExceptionHandler.java:92)
|
||||
at org.springframework.boot.devtools.restart.Restarter.immediateRestart(Restarter.java:179)
|
||||
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:163)
|
||||
at org.springframework.boot.devtools.restart.Restarter.initialize(Restarter.java:532)
|
||||
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationStartingEvent(RestartApplicationListener.java:98)
|
||||
at org.springframework.boot.devtools.restart.RestartApplicationListener.onApplicationEvent(RestartApplicationListener.java:51)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:178)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:171)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:149)
|
||||
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:137)
|
||||
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)
|
||||
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:75)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.lambda$starting$0(SpringApplicationRunListeners.java:54)
|
||||
at java.base/java.lang.Iterable.forEach(Iterable.java:75)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)
|
||||
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:54)
|
||||
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
|
||||
at com.mtkj.mtkjpay.MtkjpayApplication.main(MtkjpayApplication.java:42)
|
||||
@@ -32,8 +32,10 @@ public class MtPayApplication {
|
||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||
|
||||
// 构建完整的访问地址
|
||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
||||
// 构建完整的访问地址(开发环境使用localhost,生产环境使用配置的域名)
|
||||
String serverHost = env.getProperty("app.server.host", "localhost");
|
||||
String protocol = env.getProperty("app.server.protocol", "http");
|
||||
String baseUrl = protocol + "://" + serverHost + ":" + serverPort + contextPath;
|
||||
String apiUrl = baseUrl + "/api";
|
||||
String druidUrl = baseUrl + "/druid";
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ProductServiceImpl implements ProductService {
|
||||
@Autowired
|
||||
private BaiduTranslatorUtils baiduTranslatorUtils;
|
||||
|
||||
@Value("${server.port:18082}")
|
||||
@Value("${server.port:8082}")
|
||||
private String serverPort;
|
||||
|
||||
@Value("${server.servlet.context-path:}")
|
||||
@@ -858,7 +858,8 @@ public class ProductServiceImpl implements ProductService {
|
||||
/**
|
||||
* 从完整URL中提取链接码
|
||||
* 支持两种输入:
|
||||
* 1. 完整URL:http://localhost:3000/product/2563c74bd94c4a4b95abccf697a6c756
|
||||
* 1. 完整URL:http://localhost:3000/product/2563c74bd94c4a4b95abccf697a6c756(开发环境)
|
||||
* 或 https://shopd.mtkj2025.com/product/2563c74bd94c4a4b95abccf697a6c756(生产环境)
|
||||
* 2. 链接码:2563c74bd94c4a4b95abccf697a6c756
|
||||
*
|
||||
* @param input 用户输入的URL或链接码
|
||||
|
||||
@@ -63,7 +63,7 @@ spring:
|
||||
|
||||
# 服务器配置(所有环境通用)
|
||||
server:
|
||||
port: 18082
|
||||
port: 8082
|
||||
servlet:
|
||||
context-path: /
|
||||
# 文件上传配置
|
||||
@@ -75,11 +75,11 @@ server:
|
||||
# 文件写入磁盘的阈值(超过此大小会写入临时文件)
|
||||
file-size-threshold: 2MB
|
||||
|
||||
# 应用配置(所有环境通用)
|
||||
# 应用配置(开发环境)
|
||||
app:
|
||||
# 前端访问地址(用于生成商品详情页URL等)
|
||||
# 前端访问地址(开发环境使用localhost)
|
||||
frontend:
|
||||
url: http://175.178.252.59:3000
|
||||
url: http://localhost:3000
|
||||
|
||||
# 阿里云OSS相关配置(所有环境通用)
|
||||
aliyun:
|
||||
@@ -111,9 +111,11 @@ paypal:
|
||||
mode: sandbox
|
||||
# 是否启用PayPal支付
|
||||
enabled: true
|
||||
# Webhook URL(服务器公网地址)
|
||||
# 注意:需要在PayPal控制台配置此URL
|
||||
webhook-url: http://175.178.252.59:18082/api/paypal/webhook
|
||||
# Webhook URL(开发环境使用内网穿透或测试地址)
|
||||
# 注意:PayPal只接受HTTPS(端口443)的Webhook URL
|
||||
# 开发环境可以使用内网穿透服务(如ngrok、cpolar)或留空
|
||||
# 生产环境需要在application-prod.yml中配置
|
||||
webhook-url: https://2646b437.r33.cpolar.top/api/paypal/webhook
|
||||
# Webhook ID(从PayPal控制台获取,用于验证Webhook签名)
|
||||
webhook-id: 0SX6117212808615P
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ spring:
|
||||
|
||||
# 服务器配置
|
||||
server:
|
||||
port: ${server.port:18082}
|
||||
port: ${server.port:8082}
|
||||
servlet:
|
||||
context-path: /
|
||||
multipart:
|
||||
@@ -72,9 +72,9 @@ server:
|
||||
|
||||
# 应用配置
|
||||
app:
|
||||
# 前端访问地址
|
||||
# 前端访问地址(已配置SSL证书,使用HTTPS和域名)
|
||||
frontend:
|
||||
url: ${app.frontend.url:http://175.178.252.59:3000}
|
||||
url: ${app.frontend.url:https://shopd.mtkj2025.com}
|
||||
|
||||
# PingPong支付配置(生产环境)
|
||||
pingpong:
|
||||
@@ -99,8 +99,8 @@ paypal:
|
||||
mode: sandbox
|
||||
# 是否启用PayPal支付
|
||||
enabled: true
|
||||
# Webhook URL(部署时请修改为服务器的公网地址)
|
||||
webhook-url: ${paypal.webhook-url:https://your-domain.com/api/paypal/webhook}
|
||||
# Webhook URL(已配置SSL证书,使用HTTPS和域名)
|
||||
webhook-url: ${paypal.webhook-url:https://shopd.mtkj2025.com/api/paypal/webhook}
|
||||
# Webhook ID(从PayPal控制台获取)
|
||||
webhook-id: ${paypal.webhook-id:}
|
||||
|
||||
|
||||
@@ -46,8 +46,10 @@ public class MtkjpayApplication {
|
||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||
|
||||
// 构建完整的访问地址
|
||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
||||
// 构建完整的访问地址(开发环境使用localhost,生产环境使用配置的域名)
|
||||
String serverHost = env.getProperty("app.server.host", "localhost");
|
||||
String protocol = env.getProperty("app.server.protocol", "http");
|
||||
String baseUrl = protocol + "://" + serverHost + ":" + serverPort + contextPath;
|
||||
String apiUrl = baseUrl + "/api";
|
||||
String druidUrl = baseUrl + "/druid";
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ server:
|
||||
# 文件写入磁盘的阈值(超过此大小会写入临时文件)
|
||||
file-size-threshold: 2MB
|
||||
|
||||
# 应用配置(所有环境通用)
|
||||
# 应用配置(开发环境)
|
||||
app:
|
||||
# 前端访问地址(用于生成商品详情页URL等)
|
||||
# 前端访问地址(开发环境使用localhost)
|
||||
frontend:
|
||||
url: http://localhost:3000
|
||||
|
||||
|
||||
108
mt-startup/src/main/resources/application-prod.yml
Normal file
108
mt-startup/src/main/resources/application-prod.yml
Normal file
@@ -0,0 +1,108 @@
|
||||
spring:
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 主库数据源(生产环境)
|
||||
master:
|
||||
url: ${prod.db.url}
|
||||
username: ${prod.db.username}
|
||||
password: ${prod.db.password}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接池数量
|
||||
min-idle: 10
|
||||
# 最大连接池数量
|
||||
max-active: 200
|
||||
# 配置获取连接等待超时的时间
|
||||
max-wait: 60000
|
||||
# 配置连接超时时间
|
||||
connect-timeout: 30000
|
||||
# 配置网络超时时间
|
||||
socket-timeout: 60000
|
||||
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
|
||||
time-between-eviction-runs-millis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
min-evictable-idle-time-millis: 300000
|
||||
# 配置一个连接在池中最大生存的时间,单位是毫秒
|
||||
max-evictable-idle-time-millis: 900000
|
||||
# 配置检测连接是否有效
|
||||
validation-query: SELECT 1 FROM DUAL
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# Druid监控配置
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: ruoyi
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: false
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
|
||||
# 服务器配置
|
||||
server:
|
||||
port: ${server.port:8082}
|
||||
servlet:
|
||||
context-path: /
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 50MB
|
||||
file-size-threshold: 2MB
|
||||
|
||||
# 应用配置(生产环境)
|
||||
app:
|
||||
# 前端访问地址(已配置SSL证书,使用HTTPS和域名)
|
||||
# 支持通过环境变量覆盖:-Dapp.frontend.url=https://your-domain.com
|
||||
frontend:
|
||||
url: ${app.frontend.url:https://shopd.mtkj2025.com}
|
||||
|
||||
# PingPong支付配置(生产环境)
|
||||
pingpong:
|
||||
client-id: ${pingpong.client-id}
|
||||
acc-id: ${pingpong.acc-id}
|
||||
secret: ${pingpong.secret}
|
||||
sign-type: MD5
|
||||
gateway: https://acquirer-payment.pingpongx.com
|
||||
mode: build
|
||||
enabled: false
|
||||
|
||||
# PayPal支付配置(生产环境)
|
||||
# 注意:当前为测试环境,使用沙箱凭证
|
||||
# 正式环境需要替换为生产环境的Client ID和Secret
|
||||
paypal:
|
||||
# PayPal Client ID(API密钥)- 从环境变量或配置中心获取
|
||||
client-id: ${paypal.client-id:AdGYUZpvLuHR30dybOApvM-RNB1pVKtd74SVfh-6TK52xV-1JEBddHVMCWuDdyyHri4DXd4kABBi7Icb}
|
||||
# PayPal Client Secret(密钥)- 从环境变量或配置中心获取
|
||||
client-secret: ${paypal.client-secret:ENblspyRmwsOU_PWFurlhEYUF5Da6aYKl0pjK4ehm7p3R5aSqvbpaF_YsIIs8v0ty1c9WJu15XP-Fe_1}
|
||||
# 环境模式:sandbox(沙箱)或 production(生产)
|
||||
# 当前为测试环境,使用sandbox
|
||||
mode: ${paypal.mode:sandbox}
|
||||
# 是否启用PayPal支付
|
||||
enabled: ${paypal.enabled:true}
|
||||
# Webhook URL(已配置SSL证书,使用HTTPS和域名)
|
||||
# 支持通过环境变量覆盖:-Dpaypal.webhook-url=https://your-domain.com/api/paypal/webhook
|
||||
webhook-url: ${paypal.webhook-url:https://shopd.mtkj2025.com/api/paypal/webhook}
|
||||
# Webhook ID(从PayPal控制台获取)
|
||||
webhook-id: ${paypal.webhook-id:}
|
||||
|
||||
@@ -1,91 +1,3 @@
|
||||
spring:
|
||||
application:
|
||||
name: MTKJPAY
|
||||
profiles:
|
||||
active: dev
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
druid:
|
||||
# 从库数据源
|
||||
slave:
|
||||
# 从数据源开关/默认关闭
|
||||
enabled: false
|
||||
url:
|
||||
username:
|
||||
password:
|
||||
# Druid监控配置
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
# 设置白名单,不填则允许所有访问
|
||||
allow:
|
||||
url-pattern: /druid/*
|
||||
# 控制台管理用户名和密码
|
||||
login-username: ruoyi
|
||||
login-password: 123456
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
# 慢SQL记录
|
||||
log-slow-sql: false
|
||||
slow-sql-millis: 1000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
multi-statement-allow: true
|
||||
# MyBatis-Plus配置
|
||||
mybatis-plus:
|
||||
# 配置扫描mapper.xml文件路径
|
||||
mapper-locations: classpath*:/mapper/**/*.xml
|
||||
# 配置实体类包路径
|
||||
type-aliases-package: com.mtkj.mtpay.entity
|
||||
# 配置MyBatis-Plus全局配置
|
||||
configuration:
|
||||
# 开启驼峰命名转换
|
||||
map-underscore-to-camel-case: true
|
||||
# 开启二级缓存
|
||||
cache-enabled: false
|
||||
# 日志实现
|
||||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
# 全局配置
|
||||
global-config:
|
||||
db-config:
|
||||
# 主键类型:AUTO-数据库自增
|
||||
id-type: auto
|
||||
# 逻辑删除字段
|
||||
logic-delete-field: deleted
|
||||
# 逻辑删除值
|
||||
logic-delete-value: 1
|
||||
# 逻辑未删除值
|
||||
logic-not-delete-value: 0
|
||||
|
||||
# 服务器配置(所有环境通用)
|
||||
server:
|
||||
port: 8082
|
||||
servlet:
|
||||
context-path: /
|
||||
# 文件上传配置
|
||||
multipart:
|
||||
# 单个文件最大大小(10MB)
|
||||
max-file-size: 10MB
|
||||
# 请求最大大小(50MB,支持多文件上传)
|
||||
max-request-size: 50MB
|
||||
# 文件写入磁盘的阈值(超过此大小会写入临时文件)
|
||||
file-size-threshold: 2MB
|
||||
|
||||
# 应用配置(所有环境通用)
|
||||
app:
|
||||
# 前端访问地址(用于生成商品详情页URL等)
|
||||
frontend:
|
||||
url: http://localhost:3000
|
||||
|
||||
# 阿里云OSS相关配置(所有环境通用)
|
||||
aliyun:
|
||||
oss:
|
||||
accessId: LTAI5tHbwvzWfANvNxju2yN1
|
||||
accessKey: sAQR2swByBgmMOofH97hSJT638aVcJ
|
||||
endpoint: https://oss-cn-hangzhou.aliyuncs.com
|
||||
bucketName: mtkj2025
|
||||
|
||||
|
||||
Reference in New Issue
Block a user