Spring Boot项目 application.yml 配置赋值到 Java配置类中
application.yml
sdkConfig: # 是否为测试环境(true=是;false=否) isDevEnv: false
SdkConfig.java
import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class SdkConfig { /** * 是否测试环境开关,true连接测试环境,false连接生产环境 */ private static Boolean isDevEnv; public static Boolean getIsDevEnv() { return isDevEnv; } @Value("${sdkConfig.isDevEnv}") public void setIsDevEnv(Boolean isDevEnv) { SdkConfig.isDevEnv = isDevEnv; } }
标签:Java,Spring,Boot,isDevEnv,SdkConfig,application,yml From: https://www.cnblogs.com/tangshengwei/p/18441321