package com.estate.expert.admin.config; import com.estate.expert.admin.utils.License; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; /** * License配置类 * 负责系统启动时的License验证 */ @Component @Slf4j public class LicenseConfig implements CommandLineRunner { @Value("${license.key:}") private String licenseKey; @Override public void run(String... args) throws Exception { // log.info("=== 系统启动License验证 ==="); if (licenseKey == null || licenseKey.trim().isEmpty()) { log.error("License密钥未配置,系统无法启动"); throw new RuntimeException("License密钥未配置,系统无法启动"); } // log.info("License密钥已配置,开始验证..."); // 设置License密钥 License.setLicenseKey(licenseKey); // 初始化License验证 try { License.initializeLicenseFromConfig(); // log.info("许可验证成功,系统启动完成"); // log.info("License信息:\n{}", License.getLicenseInfo()); } catch (Exception e) { log.error("许可验证失败,系统无法启动: {}", e.getMessage()); throw e; } } }