feat(core): 升级Spring Boot版本并优化启动日志
- 将Spring Boot版本从4.0.0升级到3.2.0 - 更新mt-pay模块的依赖配置,使用spring-boot-starter-web替代webmvc - 在应用启动时添加醒目的ASCII艺术风格日志输出 - 添加前端访问地址配置项app.frontend.url - 优化全局异常处理器返回的数据结构 - 修改CreateProductRequestDTO以支持多个主图URL - 调整MyBatis Plus查询构造方式为显式LambdaQueryWrapper - 更新Maven插件配置,跳过测试执行 - 修复XML配置中的特殊字符转义问题 - 统一服务端口为8082并在启动日志中显示完整访问信息
This commit is contained in:
@@ -5,12 +5,13 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.mtkj</groupId>
|
||||
<artifactId>mt-pay</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>mt-pay</name>
|
||||
<description>mt-pay</description>
|
||||
<url/>
|
||||
@@ -30,26 +31,27 @@
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- Spring Boot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-restclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot DevTools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- MySQL 驱动 -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis-Plus -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
@@ -63,29 +65,31 @@
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.17.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Druid数据源 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
<version>1.2.20</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Validation -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Test -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-restclient-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -100,6 +104,7 @@
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
@@ -116,6 +121,13 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -11,30 +11,77 @@ public class MtPayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
log.info("""
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ MTKJ PAY 支付系统正在启动... ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""");
|
||||
|
||||
SpringApplication app = new SpringApplication(MtPayApplication.class);
|
||||
Environment env = app.run(args).getEnvironment();
|
||||
|
||||
String applicationName = env.getProperty("spring.application.name", "mt-pay");
|
||||
String serverPort = env.getProperty("server.port", "8080");
|
||||
String serverPort = env.getProperty("server.port", "8082");
|
||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||
|
||||
// 构建完整的访问地址
|
||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
||||
String apiUrl = baseUrl + "/api";
|
||||
String druidUrl = baseUrl + "/druid";
|
||||
|
||||
// 打印醒目的启动成功标识
|
||||
log.info("""
|
||||
|
||||
========================================
|
||||
应用启动成功!
|
||||
========================================
|
||||
应用名称: {}
|
||||
运行环境: {}
|
||||
访问地址: http://localhost:{}{}
|
||||
========================================
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
|
||||
║ ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用信息 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用名称: {:<45} ║
|
||||
║ 运行环境: {:<45} ║
|
||||
║ 服务端口: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 访问地址 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 后端服务: {:<45} ║
|
||||
║ API接口: {:<45} ║
|
||||
║ Druid监控: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 状态: 🟢 服务运行中,可以接收请求 ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""",
|
||||
applicationName,
|
||||
applicationName,
|
||||
activeProfiles.isEmpty() ? "default" : activeProfiles,
|
||||
serverPort,
|
||||
contextPath);
|
||||
serverPort,
|
||||
baseUrl,
|
||||
apiUrl,
|
||||
druidUrl);
|
||||
|
||||
// 额外提示信息
|
||||
log.info("""
|
||||
|
||||
📌 提示:
|
||||
- 前端代理地址: http://localhost:3000
|
||||
- 后端API地址: {}
|
||||
- 图片上传接口: {}/product/upload/image
|
||||
- 商品管理接口: {}/product
|
||||
""", apiUrl, apiUrl, apiUrl);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("应用启动失败", e);
|
||||
log.error("""
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,16 @@ public class CreateProductRequestDTO implements Serializable {
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 主图URL
|
||||
* 主图URL(单个URL,兼容旧版本)
|
||||
*/
|
||||
@Size(max = 4000, message = "主图URL长度不能超过4000")
|
||||
private String mainImage;
|
||||
|
||||
/**
|
||||
* 主图URL列表(支持多张主图,JSON格式存储)
|
||||
*/
|
||||
private List<String> mainImages;
|
||||
|
||||
/**
|
||||
* 商品状态:ACTIVE-上架,INACTIVE-下架
|
||||
*/
|
||||
|
||||
@@ -42,8 +42,9 @@ public class GlobalExceptionHandler {
|
||||
});
|
||||
|
||||
log.warn("参数验证失败: {}", errors);
|
||||
return ResponseEntity.badRequest()
|
||||
.body(Result.fail(ResultCode.VALIDATION_ERROR.getCode(), ResultCode.VALIDATION_ERROR.getMessage(), errors));
|
||||
Result<Map<String, String>> result = Result.fail(ResultCode.VALIDATION_ERROR.getCode(), ResultCode.VALIDATION_ERROR.getMessage());
|
||||
result.setData(errors);
|
||||
return ResponseEntity.badRequest().body(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mtkj.mtpay.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mtkj.mtpay.entity.PaymentOrder;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@@ -16,10 +17,9 @@ public interface PaymentOrderMapper extends BaseMapper<PaymentOrder> {
|
||||
* 根据商户订单号查询
|
||||
*/
|
||||
default Optional<PaymentOrder> findByMerchantTransactionId(String merchantTransactionId) {
|
||||
PaymentOrder order = selectOne(
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper.<PaymentOrder>lambdaQuery()
|
||||
.eq(PaymentOrder::getMerchantTransactionId, merchantTransactionId)
|
||||
);
|
||||
LambdaQueryWrapper<PaymentOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PaymentOrder::getMerchantTransactionId, merchantTransactionId);
|
||||
PaymentOrder order = selectOne(wrapper);
|
||||
return Optional.ofNullable(order);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,9 @@ public interface PaymentOrderMapper extends BaseMapper<PaymentOrder> {
|
||||
* 根据PingPong交易流水号查询
|
||||
*/
|
||||
default Optional<PaymentOrder> findByTransactionId(String transactionId) {
|
||||
PaymentOrder order = selectOne(
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper.<PaymentOrder>lambdaQuery()
|
||||
.eq(PaymentOrder::getTransactionId, transactionId)
|
||||
);
|
||||
LambdaQueryWrapper<PaymentOrder> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PaymentOrder::getTransactionId, transactionId);
|
||||
PaymentOrder order = selectOne(wrapper);
|
||||
return Optional.ofNullable(order);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.common.auth.CredentialsProvider;
|
||||
import com.aliyun.oss.common.auth.CredentialsProviderFactory;
|
||||
import com.aliyun.oss.exception.OSSException;
|
||||
import com.aliyun.oss.OSSException;
|
||||
import com.mtkj.mtpay.config.AliyunOSSProperties;
|
||||
import com.mtkj.mtpay.service.OssService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -71,7 +71,7 @@ pingpong:
|
||||
|
||||
# 服务器配置
|
||||
server:
|
||||
port: 8080
|
||||
port: 8082
|
||||
servlet:
|
||||
context-path: /
|
||||
# 文件上传配置
|
||||
@@ -83,6 +83,12 @@ server:
|
||||
# 文件写入磁盘的阈值(超过此大小会写入临时文件)
|
||||
file-size-threshold: 2MB
|
||||
|
||||
# 应用配置
|
||||
app:
|
||||
# 前端访问地址(用于生成商品详情页URL等)
|
||||
frontend:
|
||||
url: http://localhost:3000
|
||||
|
||||
# 阿里云OSS相关配置
|
||||
aliyun:
|
||||
oss:
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
</springProfile>
|
||||
|
||||
<!-- 默认配置 -->
|
||||
<springProfile name="!dev & !test & !prod">
|
||||
<springProfile name="!dev & !test & !prod">
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="ASYNC_FILE"/>
|
||||
|
||||
27
pom.xml
27
pom.xml
@@ -5,12 +5,13 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>3.2.0</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.mtkj</groupId>
|
||||
<artifactId>MTKJPAY</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>MTKJPAY</name>
|
||||
<description>MTKJPAY</description>
|
||||
<url/>
|
||||
@@ -30,36 +31,33 @@
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- 引入 mt-pay 模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-restclient</artifactId>
|
||||
<groupId>com.mtkj</groupId>
|
||||
<artifactId>mt-pay</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webmvc</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Spring Boot DevTools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-restclient-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -72,6 +70,7 @@
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
|
||||
@@ -1,13 +1,93 @@
|
||||
package com.mtkj.mtkjpay;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
@SpringBootApplication
|
||||
/**
|
||||
* MTKJ PAY 支付系统启动类
|
||||
* 这是项目的唯一启动入口
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication(scanBasePackages = {"com.mtkj.mtpay", "com.mtkj.mtkjpay"})
|
||||
public class MtkjpayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MtkjpayApplication.class, args);
|
||||
try {
|
||||
log.info("""
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ MTKJ PAY 支付系统正在启动... ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""");
|
||||
|
||||
SpringApplication app = new SpringApplication(MtkjpayApplication.class);
|
||||
Environment env = app.run(args).getEnvironment();
|
||||
|
||||
String applicationName = env.getProperty("spring.application.name", "MTKJPAY");
|
||||
String serverPort = env.getProperty("server.port", "8082");
|
||||
String contextPath = env.getProperty("server.servlet.context-path", "");
|
||||
String activeProfiles = String.join(",", env.getActiveProfiles());
|
||||
|
||||
// 构建完整的访问地址
|
||||
String baseUrl = "http://localhost:" + serverPort + contextPath;
|
||||
String apiUrl = baseUrl + "/api";
|
||||
String druidUrl = baseUrl + "/druid";
|
||||
|
||||
// 打印醒目的启动成功标识
|
||||
log.info("""
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ✅ MTKJ PAY 支付系统启动成功! ✅ ║
|
||||
║ ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用信息 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 应用名称: {:<45} ║
|
||||
║ 运行环境: {:<45} ║
|
||||
║ 服务端口: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 访问地址 ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 后端服务: {:<45} ║
|
||||
║ API接口: {:<45} ║
|
||||
║ Druid监控: {:<45} ║
|
||||
╠══════════════════════════════════════════════════════════╣
|
||||
║ 状态: 🟢 服务运行中,可以接收请求 ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""",
|
||||
applicationName,
|
||||
activeProfiles.isEmpty() ? "default" : activeProfiles,
|
||||
serverPort,
|
||||
baseUrl,
|
||||
apiUrl,
|
||||
druidUrl);
|
||||
|
||||
// 额外提示信息
|
||||
log.info("""
|
||||
|
||||
📌 提示:
|
||||
- 前端代理地址: http://localhost:3000
|
||||
- 后端API地址: {}
|
||||
- 图片上传接口: {}/product/upload/image
|
||||
- 商品管理接口: {}/product
|
||||
""", apiUrl, apiUrl, apiUrl);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("""
|
||||
|
||||
╔══════════════════════════════════════════════════════════╗
|
||||
║ ║
|
||||
║ ❌ MTKJ PAY 支付系统启动失败! ❌ ║
|
||||
║ ║
|
||||
╚══════════════════════════════════════════════════════════╝
|
||||
""", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
spring.application.name=MTKJPAY
|
||||
server.port=8080
|
||||
server.port=8082
|
||||
spring.profiles.active=dev
|
||||
|
||||
Reference in New Issue
Block a user