Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,则必须使用mvn spring-boot:run -Drun.profiles=test 如果使用命令行直接运行jar文件,则使用java -jar -Dspring.profiles.active=test demo-0.0.1-SNAPSHOT.jar 如果使用开发工具,...
一、命令行方式 命令行方式是一种外部配置的方式,在执行java -jar命令时可以通过-–spring.profiles.active=test的方式进行激活指定的profiles列表。 使用方式如下所示: java-jar order-service-v1.0.jar--spring.profiles.active=dev&>order-service.log& 注意:--spring.profiles.active的方式要在-jar之后定义。 ...
springboot启动时指定spring.profiles.active 使用命令行直接运行jar文件: java -jar -Dspring.profiles.active=test demo-0.0.1-SNAPSHOT.jar 启动进程 nohup java -jar demo-0.0.1-SNAPSHOT.jar > log.file 2>&1 & 上面的2 和 1 的意思如下: /dev/null 表示空设备文件 0 stdin标准输入(一般是键盘) 1...
1.上面提到的application.properties设置spring.profile.active的值。 2.命令行中指定参数 通过指定jvm系统参数 java -jar -Dspring.profiles.active=prod springboot-profile-demo 0.0.1-SNAPSHOT.jar 1. 通过指定应用参数 java -jar --spring.profiles.active=dev springboot-profile-demo 0.0.1-SNAPSHOT.jar 1....
spring boot允许你通过命名约定按照一定的格式(application-{profile}.properties)来定义多个配置文件,然后通过在application.properyies通过spring.profiles.active来具体激活一个或者多个配置文件,如果没有没有指定任何profile的配置文件的话,spring boot默认会启动application-default.properties。
spring-boot:run启动时,指定spring.profiles.active Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,则必须使用mvn spring-boot:run -Drun.profiles=test 如果使用命令行直接运行jar文件,则使用java -jar -Dspring.profiles.active=...
Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,spring-boot 1.x 使用mvn spring-boot:run -Drun.profiles=test,spring-boot 2.x 使用mvn spring-boot:run -Dspring-boot.run.profiles=test。参考资料:https://docs.spring....
Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,spring-boot 1.x 使用mvn spring-boot:run -Drun.profiles=test,spring-boot 2.x 使用mvn spring-boot:run -Dspring-boot.run.profiles=test。
在打开的“Run/Debug Configurations”对话框中,选择你的Spring Boot应用配置。 在右侧的“Environment”选项卡中,你可以看到一个名为“Active Profiles”的字段。 在这个字段中,输入你想要在本地启动时激活的Spring Profiles。例如,如果你想要激活名为“dev”的Profile,你可以输入--spring.profiles.active=dev。 点击...
Maven启动指定Profile通过-P,如mvn spring-boot:run -Ptest,但这是Maven的Profile。 如果要指定spring-boot的spring.profiles.active,spring-boot 1.x 使用mvn spring-boot:run -Drun.profiles=test,spring-boot 2.x 使用mvn spring-boot:run -Dspring-boot.run.profiles=test。