【发布时间】:2019-05-28 00:08:57
【问题描述】:
这是我的 application.yml 文件:
spring:
freemarker:
template-loader-path: classpath:/templates
datasource:
url: jdbc:postgresql://localhost:5432/myapp
username: postgres
password: password
driver-class-name: org.postgresql.Driver
jpa:
show-sql: true
properties:
hibernate:
enable_lazy_load_no_trans: false
jdbc:
lob:
non_contextual_creation: true
dialect: org.hibernate.dialect.PostgreSQLDialect
hibernate:
ddl-auto: create-drop
---
spring:
profiles:
active: development
---
spring:
profiles: staging
jpa:
show-sql: true
hibernate:
ddl-auto: update
logging:
level:
root: DEBUG
---
spring:
profiles: production
jpa:
show-sql: false
hibernate:
ddl-auto: update
我使用以下方式运行应用程序:
java -jar application.jar -Dspring.profiles.active=staging
在日志中,我可以看到 spring boot 打印出来: 以下配置文件处于活动状态:开发
那么为什么即使我在命令行参数中明确设置了活动配置文件,也没有将其设置为staging?
【问题讨论】:
标签: java spring spring-boot spring-profiles