I am doing an application with Grails 2.5.3 version. I want to outsource the database code and the section of Log4j.
The code of Log4j is in a external .groovy file. This file won't be modified by user so it is not necessary to be a properties file in /classes dir. The best in the case of database code is to have several features in a external properties file because will continue being a properties file in /classes dir. Also, DataSource.groovy exists with the rest of the configuration.
Then, I have only achieved to work Log4j conf with:
grails.config.locations = ["file:./grails-app/conf/LogConfig.groovy"]
With classpath doesn't work though I put the file in /grails-app/conf dir. This doesn't work:
grails.config.locations = ["classpath:LogConfig.groovy"]
Also, I have added both cases (run-app and war mode). However, when I run grails prod war and deploy Tomcat, Logconfig.groovy is not recognize.
grails.config.locations = ["file:./grails-app/conf/LogConfig.groovy",
"classpath:LogConfig.groovy"]
And in the case of database code, I didn't achieve to work the .properties file. This file I put in grails-app/conf and its contain is:
# DB properties
dataSource.username = xxx
dataSource.password = xxx
dataSouce.driverClassName = xxx
environments.development.dataSource.url = jdbc:mysql://localhost/xxx
environments.test.dataSource.url = jdbc:mysql://localhost/xxx
environments.production.dataSource.url = jdbc:mysql://localhost/xxx
I have read many tutorial and blogs and I don't know how I can do it to work.
Thanks for the help.