feat(core): 初始化支付系统核心配置与启动模块
- 添加Druid主从数据源配置属性类 - 创建支付系统主启动类MtkjpayApplication - 配置mt-startup模块pom.xml引入必要依赖 - 添加RestClient配置类用于HTTP请求 - 创建统一响应结果类Result及响应码枚举 - 实现美观的系统启动成功/失败日志输出 - 配置Lombok注解处理器支持
This commit is contained in:
82
mt-startup/pom.xml
Normal file
82
mt-startup/pom.xml
Normal file
@@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.mtkj</groupId>
|
||||
<artifactId>MTKJPAY</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>mt-startup</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>mt-startup</name>
|
||||
<description>MTKJ PAY 启动模块</description>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<lombok.version>1.18.30</lombok.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 引入 mt-pay 模块 -->
|
||||
<dependency>
|
||||
<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-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Boot DevTools -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* MTKJ PAY 支付系统启动类
|
||||
* 这是项目的唯一启动入口
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = {"com.mtkj.mtpay", "com.mtkj.mtkjpay"},
|
||||
exclude = {
|
||||
com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure.class
|
||||
}
|
||||
)
|
||||
public class MtkjpayApplication {
|
||||
|
||||
public static void main(String[] 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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user