package org.xyzh.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;

/**
 * @description Gateway 网关启动类
 * @author yslg
 * @since 2025-12-02
 */
@SpringBootApplication(exclude = {
    DataSourceAutoConfiguration.class  // Gateway 不需要数据源
})
@EnableDiscoveryClient
@ComponentScan(
    basePackages = {
        "org.xyzh.gateway",    // 当前 gateway 模块
        "org.xyzh.common"      // 公共模块（包括 common-auth）
    },
    excludeFilters = {
        // 使用正则表达式排除 Spring MVC 相关配置，避免加载 WebMvcConfigurer 类
        @ComponentScan.Filter(type = FilterType.REGEX, pattern = {
            "org\\.xyzh\\.common\\.auth\\.config\\.SecurityConfig",
            "org\\.xyzh\\.common\\.auth\\.config\\.WebMvcConfig",
            "org\\.xyzh\\.common\\.auth\\.config\\.GatewayAuthConfig",
            "org\\.xyzh\\.common\\.utils\\.config\\.FastJsonConfiguration"
        })
    }
)
public class GatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
        System.out.println("========================================");
        System.out.println("    Gateway 网关服务启动成功！");
        System.out.println("========================================");
    }
}
