Advertisement

Spring Boot 根据配置类动态加载不同环境下的自定义配置

阅读量:

开发环境配置实践

复制代码
    @Profile({"dev","test"})
    @PropertySource("classpath:dev.properties")
    public class DevConfigLoader {
    }
    
    
      
      
      
      
    
复制代码
    @Profile("prod")
    @PropertySource("classpath:prod.properties")
    public class ProdConfigLoader {
    }
    
    
      
      
      
      
    

@Profile 注解具备依据当前运行环境自动加载对应配置类的功能,而@PropertySource 则用于引入位于其他 jar 包内部的 classpath 资源文件。

全部评论 (0)

还没有任何评论哟~