1

I want to use external property file for database configuration in production environment. i have tried some of solution from blogs and stack overflow but its work only for development environment.

grailsVersion=3.3.2
Kapil Thakkar
  • 840
  • 10
  • 17

1 Answers1

0

First create properties file in src/main/resources (if resources dir does not exist, create it).

then remove configuration from application.yml (if won't then it will override). in Application.groovy load the file with this :

def url = getClass().classLoader.getResource("myconfig.properties")
def confFile = new File(url.toURI())
Properties properties = new Properties()
confFile.withInputStream {
  properties.load(it)
}

environment.propertySources.addFirst(new PropertiesPropertySource("local.config.location", properties))
Kapil Thakkar
  • 840
  • 10
  • 17