原文:SpringBoot中获取spring.profiles.active的值

一 网上很多采用 Profile dev 的方式获取,但是这个是类级别的 二 开发中可能需要代码级别 刚开始我想通过classpath下的文件读取方式,麻烦死了,于是换了个思路。 SpringBoot启动日志中有下面这句: : : . restartedMain INFO c.d.o.OptplatformApplication The following profiles are active: ...

2018-05-18 16:14 3 27689 推荐指数:

查看详情

mvn spring.profiles.active

Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,则必须使用mvn spring-boot:run -Drun.profiles ...

Thu Nov 21 00:18:00 CST 2019 0 364
springBoot 入门(二)—— 使用 spring.profiles.active来区分配置

背景很多时候,我们项目在开发环境和生成环境的环境配置是不一样的,例如,数据库配置,在开发的时候,我们一般用测试数据库,而在生产环境的时候,我们是用正式的数据,这时候,我们可以利用profile在不同的环境下配置用不同的配置文件或者不同的配置。 spring boot 提供spring boot ...

Mon Apr 04 03:51:00 CST 2022 0 2614
springboot如何动态更换 配置文件 spring.profiles.active

maven可以动态更换配置文件,但是不同profile打包使用的命令不同, dev,test,prod就要打包3次, 如果项目是springboot的项目,就可以使用spring.profiles.active来进行一次打包,多个环节都可以运行。 下面就介绍下步骤: (1), 创建 ...

Sat Mar 24 04:11:00 CST 2018 0 1512
spring.profiles.active=@profiles.active@用法

1.引言 当在多配置文件,需要切换配置文件时,通常的做法都是修改激活的文件名称,而spring.profiles.active=@profiles.active@ 是配合 maven profile进行选择不同配置文件进行启动,可以避免修改文件,而在maven打包是指定使用哪个配置文件 ...

Sun Jun 27 00:35:00 CST 2021 0 315
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM