首页 > 解决方案 > Spring Cloud 配置不应用全局配置

问题描述

我在 spring cloud 配置 2020.0.3、spring boot 2.4.5 上遇到问题,详情:

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"

引导程序.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

请帮助我,非常感谢!

标签: spring-bootspring-cloud

解决方案


spring:
  profiles:

This does not exist (it was deprecated if I am not mistaken). Please check the reference documentation.

I believe that what you are looking for is the following (reference documentation):

spring:
  datasource:
    url: "jdbc:mariadb://localhost:3306/default_db"
    driver-class-name: org.mariadb.jdbc.Driver
    username: my_db
    password: 12345
---
spring:
  config:
    activate:
      on-profile: dev
  datasource:
    url: "jdbc:mariadb://localhost:3306/dev_db"

推荐阅读