首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    springBoot 入门(二)—— 使用 spring.profiles.active来区分配置

    在这里可以看到spring.profiles.active激活的profile不同,打印出来的结果也不一样。...所以: 除了spring.profiles.active来激活一个或者多个profile之外,还可以用spring.profiles.include来叠加profile 例如,刚刚我想让java中配置的...如:spring.profiles.active=test就会加载application-test.properties配置文件内容 下面,以不同环境配置不同的服务端口为例,进行样例实验。...80,也就是生产环境的配置(prod) 按照上面的实验,可以如下总结多环境的配置思路: application.properties中配置通用内容,并设置spring.profiles.active=...在application.properties中加入: spring.profiles.active=dev 通过命令行参数 java -jar app.jar --spring.profiles.active

    19.8K22

    8-SpringBoot配置-profile

    application-pro.properties/yml 生产环境 yml多文档方式: 在yml中使用 --- 分隔不同配置 3. profile激活方式 配置文件:再配置文件中配置:spring.profiles.active...=dev 虚拟机参数:在VM options 指定:-Dspring.profiles.active=dev 命令行参数:java –jar xxx.jar --spring.profiles.active...profile激活方式 配置文件:再配置文件中配置:spring.profiles.active=dev 虚拟机参数:在VM options 指定:-Dspring.profiles.active=dev...命令行参数:java –jar xxx.jar --spring.profiles.active=dev 在上面我们在配置文件编写的过程中,切换环境都是使用配置文件。...=dev 1.配置启动的命令 --spring.profiles.active=dev 2.确认启动的效果 3.Jar包使用命令行参数 首先打一个jar包,使用命令行启动如下: “注意:打包的时候将其他没有用的配置文件删除

    1.5K21

    Spring Boot 中如何配置 Profile

    关键词: @Profile、spring.profiles.active 目录 区分环境的配置 properties 配置 yml 配置 区分环境的代码 修饰类 修饰注解 修饰方法 激活 profile...application-test.properties - 测试环境配置 application-prod.properties - 生产环境配置 在 applcation.properties 文件中可以通过以下配置来激活 profile: spring.profiles.active...yml 文件也可以在一个文件中完成所有 profile 的配置: # 激活 prod spring: profiles: active: prod # 也可以同时激活多个 profile # spring.profiles.active...datasource"); } } 激活 profile 插件激活 profile spring-boot:run -Drun.profiles=prod main 方法激活 profile --spring.profiles.active...jar -Dspring.profiles.active=prod *.jar 在 Java 代码中激活 profile 直接指定环境变量来激活 profile: System.setProperty("spring.profiles.active

    1.1K30

    深入Spring Boot:Profile隔离环境配置的源码与实战

    prod") // 非生产环境生效 spring.profiles.active的配置艺术 spring.profiles.active属性是控制当前激活Profile的关键,它可以通过多种方式设置...: application.properties/yml: spring.profiles.active=dev 命令行参数: java -jar app.jar --spring.profiles.active...此时会优先读取spring.profiles.active的配置值,这个属性可以来自: 命令行参数(–spring.profiles.active=dev) 系统环境变量(SPRING_PROFILES_ACTIVE...@Profile与spring.profiles.active的关系 在Spring Boot的多环境配置体系中,@Profile注解和spring.profiles.active属性如同DNA双螺旋结构般紧密缠绕...spring.profiles.active则是Spring Boot的核心配置属性,用于显式声明当前激活的环境profile。

    56410

    Spring Boot 之 Profile 使用

    关键词: @Profile、spring.profiles.active 区分环境的配置 properties 配置 假设,一个应用的工作环境有:dev、test、prod 那么,我们可以添加 4...application-test.properties - 测试环境配置 application-prod.properties - 生产环境配置 在 applcation.properties 文件中可以通过以下配置来激活 profile: spring.profiles.active...yml 文件也可以在一个文件中完成所有 profile 的配置: # 激活 prod spring: profiles: active: prod # 也可以同时激活多个 profile # spring.profiles.active...datasource"); } } 激活 profile 插件激活 profile spring-boot:run -Drun.profiles=prod main 方法激活 profile --spring.profiles.active...jar -Dspring.profiles.active=prod *.jar 在 Java 代码中激活 profile 直接指定环境变量来激活 profile: System.setProperty("spring.profiles.active

    94110
    领券