springboot 多profile配置
来源:互联网 发布:js弹出图片窗口 编辑:程序博客网 时间:2024/06/06 14:12
一般来说,我们所有的配置都在application.properties里面,
这个时候我们可以分多个配置文件适配不同的环境。
开发环境
连接本地数据库
用户名
密码
日志存放在F盘的xxx目录
生产环境
服务器数据库
用户名
密码
日志存放在 /root/xxx之类的linux目录上
好,开始
在根目录(resources)下,有三个属性文件,除了application.properties,还有一个开发环境属性和生产环境属性的文件,需要遵循application-{profile}.properties这种命名格式,这样就能提供特定于profile的属性了。
在application.properties里先指定用哪一种环境
#生产环境spring.profiles.active=prod
这样,程序就会选用prod文件里配置的数据库和日志目录等相应的属性
所有环境可以共用的属性就放在application.properties 就好
不同环境下属性值不同的在各自对应的环境中配置
例如:
一般开发环境下日志的级别是dubug
开发环境
server.port=8866spring.jpa.hibernate.ddl-auto=updatespring.jpa.show-sql = truespring.datasource.url=jdbc:mysql://localhost:3306/scholarship?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=truespring.datasource.username=rootspring.datasource.password=rootlogging.path=F:\\ANDLINKS-PROJECT\\Andlinks-Yourturn\\logslogging.file=devlog.loglogging.level.root=debug
生产环境下日志级别是warn或者更高级
生产环境:
server.port=8855spring.jpa.hibernate.ddl-auto=updatespring.jpa.show-sql = truespring.datasource.url=jdbc:mysql://192.168.1.22:3306/scholarship?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=truespring.datasource.username=rootspring.datasource.password=andlinkslogging.path=/root/ch/black/logslogging.file=pro.loglogging.level.root=warn
阅读全文
0 0
- springboot 多profile配置
- 19-SpringBoot——核心-Profile配置
- SpringBoot--Profile
- SpringBoot14-springboot核心-外部配置,日志配置,Profile配置
- SpringBoot学习(三)--Spring profile多环境方式实现logback日志配置
- SpringBoot使用profile配置不同环境配置生效
- springboot + profile(不同环境读取不同配置)
- 第十四章 springboot + profile(不同环境读取不同配置)
- springboot + profile(不同环境读取不同配置)
- Profile-多环境配置
- SpringBoot之开启Profile
- SpringBoot学习笔记二(常规属性配置,类型安全配置,日志配置,Profile配置)
- springboot 配合 profile 多环境自动切换配置文件
- SpringBoot 多文件配置.
- springboot多环境配置
- maven profile多环境配置
- spring多环境变量配置 @profile
- Profile配置
- Python安装
- 刷oj应该注意的问题
- HTTP常见错误
- JavaScript中数组操作常用方法
- Hibernate之关联映射(下)
- springboot 多profile配置
- 动态规划--找零钱有多少种方法
- 对象怎样才算相等
- lua 退出APP
- 【PAT】【Advanced Level】1100. Mars Numbers (20)
- spring与mybatis三种整合方法
- 深入理解DIP、IoC、DI以及IoC容器
- 493. Reverse Pairs 逆序数 类似剑指offer
- hydra