spring boot之多环境配置
来源:互联网 发布:大数据r语言 编辑:程序博客网 时间:2024/05/18 01:08
一.多环境配置的好处:
1.不同环境配置可以配置不同的参数
2.便于部署,提高效率,减少出错
二.Properties多环境配置
1. application.properties中配置激活选项
spring.profiles.active=dev
2.添加其他配置文件
application-dev.properties—》server.port=8080
application-test.properties—》server.port=8090
application-prod.properties—》server.port=80
三.application.yaml多环境配置
配置文件环境配置
spring:
profiles:
active: dev
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Chongqing
spring:
profiles: dev
server:
port: 8080
spring:
profiles: test
server:
port: 8090
spring:
profiles: prod
server:
port: 80
四.两种配置方式的比较
1.Properties配置多环境,需要添加多个配置文件,YAML只需要一个配件文件
2.书写格式的差异,yaml相对比较简洁,优雅
3.YAML的缺点:不能通过@PropertySource注解加载。如果需要使用@PropertySource注解的方式加载值,那就要使用properties文件。
五.如何使用
java -jar myapp.jar –spring.profiles.active=dev
- spring boot之多环境配置
- 51. spring boot属性文件之多环境配置【从零开始学Spring Boot】(
- 51. spring boot属性文件之多环境配置【从零开始学Spring Boot】
- 51. spring boot属性文件之多环境配置【从零开始学Spring Boot】
- 51. spring boot属性文件之多环境配置【从零开始学Spring Boot】
- ing boot属性文件之多环境配置【从零开始学Spring Boot】
- spring boot之多数据源
- spring boot 多环境配置
- spring boot 开发环境配置
- Spring Boot简单环境配置
- spring boot jpa之多数据源
- Spring Boot环境配置:Spring Boot+Mybatis+Gradle
- spring boot中多环境配置支持
- Spring Boot配置文件-多环境配置
- spring boot 中logback多环境配置
- spring boot的使用以及环境配置
- Spring Boot-配置文件-多环境配置
- Spring Boot配置文件-多环境配置
- 之前的博客写满了,搬家到这里
- 冒泡排序
- (27)Dubbo的Provider和consumer(springmvc)搭建完成-goodjob!
- xposed模块开发步骤总结
- hihoCoder挑战赛29 D.不上升序列
- spring boot之多环境配置
- 关于我尽可能多的一切
- 【简记】Operating System——Atomic Transaction Overview
- spring+springMVC+Mybatis在maven工程的搭建总结
- oracle---操作占用,卡住
- oracle之sql
- Eclipse快捷键
- select for update nowait 与 select for update 区别
- org-springframework-beans-NotWritablePropertyException--Invalid property 问题