SpringBoot环境配置文件
- Spring Boot可针对不同的环境提供不同的Profile文件。
- Profile文件的默认命名格式为application-{env}.yml
- 使用spring.profiles.active选项来指定不同的profile
学习视频: http://www.itlaoqi.com/chapter/1685.html
源码地址: QQ群 814077650 , 群共享中自助下载
老齐的官网: itlaoqi.com (更多干货就在其中)
application.yml
spring:
profiles:
active: dev #改为prd就是线上配置
application-dev.yml
#debug=true
debug: false
#server.port=80
#前缀相同的配置项,idea会自动进行归纳
server:
port: 8000
servlet:
context-path: /
thymeleaf:
cache: false
spring:
mvc:
date-format: yyyy-MM-dd
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test
username: root
password: root
application-prd.yml
#debug=true
debug: false
#server.port=80
#前缀相同的配置项,idea会自动进行归纳
server:
port: 80
servlet:
context-path: /
#idean对yml有良好支持可自动生成
spring:
thymeleaf:
cache: false
mvc:
date-format: yyyy-MM-dd
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://166.87.93.124:3310/production
username: admin
password: [email protected]#$
原文地址:https://www.cnblogs.com/itlaoqi/p/11391745.html
时间: 2025-01-09 04:47:41