【问题标题】:Grails 3 (GORM) datasource properties not loading from Spring Cloud Config ServerGrails 3 (GORM) 数据源属性未从 Spring Cloud Config Server 加载
【发布时间】:2015-11-22 22:21:19
【问题描述】:

我正在尝试使用 Spring Cloud Config Server 来外部化我的 Grails 3(人员)应用程序配置,但我似乎无法设置 dataSource 属性。

目前,我可以将其他属性 (sample.message) 加载到我的 Grails 3(人员)应用程序中,并使用 grailsApplication.config.sample.message 检索它们而不会出现问题。并且在配置服务器(localhost:8888/personnel/master)上点击 REST 端点正在显示我想要的配置信息,所以我有点困惑。

我在我的 Git 存储库中的 personnel.properties 文件中尝试了以下各项:

datasource.user=example
datasource.password=example

grails.datasource.user=example
grails.datasource.password=example

spring.datasource.user=example
spring.datasource.password=example

但它们都不起作用。我继续看到错误消息说sa@localhost (using password: no),特别是表明数据源属性不起作用。

我知道spring-boot-starter-data-jpa 是可能的,所以我想知道:

  1. GORM 可以吗?
  2. 如果需要,是否需要手动创建数据源 bean?
  3. 我使用哪些属性名称datasource.usergrails.datasource.userspring.datasource.user 等?

【问题讨论】:

    标签: grails spring-cloud grails-3.0


    【解决方案1】:

    经过 Shashank 的编辑后,我意识到这是我的属性设置的问题。 datasource 应该是 dataSourceuser 应该是 username。一旦进行了这些更正,应用程序(人员)就可以完美运行。所以,

    1. 是的,这是可能的。
    2. 不,您不需要手动创建 bean
    3. 属性名称是:

    personnel.properties

    dataSource.username=example
    dataSource.password=example
    dataSource.url=jdbc:mysql://localhost:3306/personnel
    

    【讨论】:

      猜你喜欢
      • 2021-03-22
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 2021-05-25
      • 2020-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多