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; } } }