标签:character localhost img odi 配置文件 分割 col info roo
spring: # 环境 dev:开发环境|test:测试环境|prod:生产环境 profiles: active: dev #激活的配置文件
在激活application-dev.yml时若其中存在application.yml同名配置时后者的配置属性会被覆盖(即激活配置文件优先级高于总配置文件)
用---实现多文件内容的分割,application.yml中用spring.profiles.active: 实现指定的文件
spring: profiles.active: dev # 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如: # 测试环境:java -jar spring-boot.jar --spring.profiles.active=test # 生产环境:java -jar spring-boot.jar --spring.profiles.active=prod --- # 开发环境配置 spring: profiles: dev datasource: url: jdbc:mysql://127.0.0.1:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC username: root password: root driver-class-name: com.mysql.jdbc.Driver server: port: 8080 --- # 测试环境配置 spring: profiles: test datasource: url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC username: root password: test driver-class-name: com.mysql.jdbc.Driver server: port: 88 --- # 生产环境配置 spring: profiles: prod datasource: url: jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC username: root password: prod driver-class-name: com.mysql.jdbc.Driver
标签:character localhost img odi 配置文件 分割 col info roo
原文地址:https://www.cnblogs.com/aeolian/p/12346633.html