dspies
dspies

Reputation: 1543

Grails 3 (GORM) datasource properties not loading from Spring Cloud Config Server

I am trying to use Spring Cloud Config Server to externalize my Grails 3 (personnel) application configuration, but I cannot seem to set the dataSource properties.

Currently, I can load other properties (sample.message) into my Grails 3 (personnel) application and retrieve them using grailsApplication.config.sample.message without an issue. And hitting the REST endpoint on the Config Server (localhost:8888/personnel/master) is showing the configuration information I want, so I'm a bit confused.

I have tried each of the following in my personnel.properties file in my Git repo:

datasource.user=example
datasource.password=example

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

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

But none of them work. I continue to see error messages saying sa@localhost (using password: no) suggesting that the datasource properties, in particular, are not working.

I know it is possible with spring-boot-starter-data-jpa, so I'm wondering:

  1. Is it possible with GORM?
  2. If so, do I need to manually create the datasource bean?
  3. What property names do I use datasource.user, grails.datasource.user, spring.datasource.user, etc?

Upvotes: 1

Views: 384

Answers (1)

dspies
dspies

Reputation: 1543

After Shashank's edit, I realized that it was an issue with my property settings. datasource should have been dataSource and user should be username. Once those corrections were made, the application (personnel) worked perfectly. So,

  1. Yes it is possible.
  2. No, you don't need to create the bean manually
  3. Property names are:

personnel.properties

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

Upvotes: 1

Related Questions