美文网首页
多环境配置

多环境配置

作者: firehole | 来源:发表于2017-03-22 12:40 被阅读0次

    1,增加依赖:spring-boot-configuration-processor

    2,@ConfigurationProperties(prefix="com.kfit.blog")在类上注解

    3,在启动类上加注解 @EnableConfigurationProperties({BlogProperties.class})

    4,在application.property里 配置随机数

    # 10以内的随机数

    com.kfit.blog.test1=${random.int(10)}

    5,多环境配置

    5.1,在Spring Boot中多环境配置文件名需要满足application-{profile}.properties的格式,其中{profile}对应你的环境标识

    5.2,至于哪个具体的配置文件会被加载,需要在application.properties文件中通过spring.profiles.active属性来设置,其值对应{profile}值

    5.3,对于一些只需要在特定环境才可能执行的server,加注解@Profile("prod")//生产环境.

    在application.properties文件中通过spring.profiles.active属性来激活

    相关文章

      网友评论

          本文标题:多环境配置

          本文链接:https://www.haomeiwen.com/subject/fzhonttx.html