“mitao”
2026-05-16 881332a25bcbbe3bebb696f6d0728fba559ef635
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
        }
    }
}