将application.yml 做为静态在JAVA文件中属性读取
@Component
@ConfigurationProperties(prefix = "myData")
public class MyDataConfig
{
private static String profile;
public static String getProfile()
{
return profile;
}
public void setProfile(String profile)
{
MyDataConfig.profile = profile;
}
}
对应application.yml
# 项目相关配置
myData:
profile: userinfo