【发布时间】:2021-09-04 15:09:57
【问题描述】:
我在spring cloud配置2020.0.3,spring boot 2.4.5遇到问题,详情:
- Yaml 配置文件如下Multi-profile YAML documents
- 我在配置服务器上有一个配置 yaml 文件。
my_cofig.yaml
spring:
datasource:
url: "jdbc:mariadb://localhost:3306/default_db"
driver-class-name: org.mariadb.jdbc.Driver
username: my_db
password: 12345
---
spring:
profiles: dev
datasource:
url: "jdbc:mariadb://localhost:3306/dev_db"
- 我已经通过浏览器从配置服务器加载了配置,是正确的。 但是:
- 当我使用特定配置(例如 dev)运行 Spring 应用程序时,Spring 应用程序不能应用配置服务器上配置文件中定义的全局配置变量。它只加载 dev 的配置变量。
bootstrap.yaml
server:
port: 8081
spring:
application:
name: auth-service
cloud:
config:
enabled: true
fail-fast: true
allow-override: true
profile: dev
uri: http://localhost:5000
错误详情:
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
请帮助我,非常感谢!
【问题讨论】:
-
此处不可见,但您是否在
profiles中添加了空格? yaml 在空格和制表符方面非常引人注目 -
感谢您的评论,yaml 格式正确!
-
/actuator/env 说什么?什么版本的spring boot?
-
我使用的是 Spring Boot 版本:2.4.5。控制台日志:原因:org.hibernate.HibernateException:当未设置“hibernate.dialect”时,对 DialectResolutionInfo 的访问不能为空