- 上一篇讲了配置文件的自动装配,这一片讲一下静态装配
import lombok.Data; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix = "app") @Data public class CustomProperties { public static String appid; public static String appkey; public static String secretkey; @Value("${app.appid}") public void setAppid(String appid) { CustomProperties.appid = appid; } @Value("${app.appkey}") public void setAppkey(String appkey) { CustomProperties.appkey = appkey; } @Value("${app.secretkey}") public void setSecretkey(String secretkey) { CustomProperties.secretkey = secretkey; } }
SpringBoot 配置文件的静态装配
于 2021-04-12 09:54:21 首次发布