SpringBoot静态类读取配置文件的用法

配置文件的值

#项目配置
# 文件路径
project.profile=C:/Users/Administrator/Desktop/Project
# 实例演示开关
project.demoEnabled=true

静态类的写法

@Component
@ConfigurationProperties(prefix = "project")
public class ProjectConfig {
    /** 实例演示开关 */
    private static boolean demoEnabled;
    public void setDemoEnabled(boolean demoEnabled)
    {
        ProjectConfig.demoEnabled = demoEnabled;
    }
    public static boolean isDemoEnabled()
    {
        return demoEnabled;
    }

    /** 上传路径 */
    private static String profile;
    public void setProfile(String profile)
    {
        ProjectConfig.profile = profile;
    }
    public static String getProfile(){return profile;}
}

你可能感兴趣的:(SpringBoot,spring,boot,后端,java)