Posts Tagged ‘datasource’

Externalize datasource configuration in Grails

March 11, 2010

the following seems to work to externalize datasource configuartion (see http://jira.codehaus.org/browse/GRAILS-3226?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel)
Basically
1) you add the grails.config.locations property in the Config.groovy like below

grails.config.locations = [ //”classpath:${appName}-config.properties”,
//”classpath:${appName}-config.groovy”,
“file:${userHome}/${appName}-config.properties”]

Notice: I have added the file is users file system , so the user can change it, without touching the war file . Restarting the app should pick up the new value
2) in the ${appName}-config.properties” file

dataSource.driverClassName = com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://localhost/something
dataSource.username=root
dataSource.password=secret

Notice no quotes in the value
I am using grails 1.2.1