Files
MTKJPAY/mt-pay/src/main/java/com/mtkj/mtpay/MtPayApplication.java
qiube 48dc5acddc refactor(config): 重构应用配置文件结构
- 将application.yml中的配置项按环境分离到对应配置文件
- 在application-dev.yml中添加服务器和应用配置
- 在application-prod.yml中添加生产环境支付配置
- 在application-test.yml中添加测试环境支付配置
- 删除application-paypal-example.yml示例文件
- 在主应用类中启用PingPong配置属性支持
- 更新配置文件激活方式为profiles模式
2025-12-23 16:03:10 +08:00

93 lines
5.7 KiB
Java

package com.mtkj.mtpay;
import com.mtkj.mtpay.config.PingPongProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.core.env.Environment;
@Slf4j
@SpringBootApplication
@EnableConfigurationProperties({PingPongProperties.class})
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", "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;
}
}
}