secondbreakfast
secondbreakfast

Reputation: 4372

How to externalize Grails data config

I am working on a Grails project that needs to be able to change it's data source once the WAR file is deployed to a server. How can I do this? I have tried the method listed here https://translate.google.com/translate?sl=auto&tl=en&js=y&prev=_t&hl=en&ie=UTF-8&u=http%3A%2F%2Flaurobecker.wordpress.com%2F2011%2F03%2F25%2Fdatasource-arquivo-properties%2F&edit-text=&act=url as well as here Externalizing Grails Datasource configuration but they do not seem to be working for me. Can someone explain this entire process to me, and what my options are? I have never done this before so forgive me if my question isnt very technical. Thanks!

Upvotes: 0

Views: 93

Answers (1)

Mario David
Mario David

Reputation: 1615

As i know, there are two options available. the first one is, as described here and in the official docs, that you can split your config.groovy in different files. So you can also include files from the classpath, the home directory of the current user and so on. The example from the docs is:

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

The other approach is, that you can set a JNDI Parameter in the app server and use this in your config.groovy as described here in the offical docs:

dataSource {
  jndiName = "java:comp/env/myDataSource"
}

Upvotes: 2

Related Questions