package com.iailab.sdk.auth.config; import org.springframework.context.annotation.Configuration; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * SDK配置文件 */ @Configuration public class SdkConfiguration { private String baseUrl; public String getTenantId() { return tenantId; } private String tenantId; public static SdkConfiguration load() { SdkConfiguration config = new SdkConfiguration(); try(InputStream is = SdkConfiguration.class.getResourceAsStream("/application.yaml")) { Properties props = new Properties(); props.load(is); config.baseUrl = props.getProperty("base-url"); config.tenantId = props.getProperty("tenant-id"); } catch (IOException e) { // 处理异常或使用默认值 } if(config.baseUrl == null) { throw new IllegalStateException("BaseUrl must be configured"); } if(config.tenantId == null) { throw new IllegalStateException("TenantId must be configured"); } return config; } public String getBaseUrl() { return baseUrl; } }