Похоже, любые опции, добавленные через grails.config.locations, недоступны в Config.groovy. "$ {System.getProperty ('password')}". ToString () - единственный способ, которым это работает.
Вот мои результаты теста:
Добавлено в начале Config.groovy:
if (new File("${userHome}/.grails/${appName}-config.groovy").exists()){
grails.config.locations = ["file:${userHome}/.grails/${appName}-config.groovy"]
}
Добавлено в конце Config.groovy:
println "(*) grails.config.locations = ${grails.config.locations}"
def f = new File("${userHome}/.grails/${appName}-config.groovy")
f.eachLine{ line -> println line }
println "test password: ${testPassword}" // same result ([:]) with grails.config.testPassword
println "${System.getProperty('password')}"
grails.naming.entries = ['jdbc/test_mnr': [
type: "javax.sql.DataSource", //required
auth: "Container", // optional
description: "Data source for ...",
url: "jdbc:oracle:thin:@server:1521:SID",
username: "username",
password: "${System.getProperty('password')}".toString(),
driverClassName: "oracle.jdbc.driver.OracleDriver",
maxActive: "8",
maxIdle: "4",
removeAbandoned: "true",
removeAbandonedTimeout: "60",
testOnBorrow: "true",
logAbandoned: "true",
factory: "org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory",
validationQuery: "select count(*) from dual",
maxWait: "-1"
]
]
Содержимое user.home / .grails / mnroad-config.groovy:
testPassword='some_password'
Вот результат при запуске с -Dpassword = somePassword:
(*) grails.config.locations = [file:C:\Documents and Settings\carr1den/.grails/mnroad-config.groovy]
testPassword=some_password
test password: [:]
somePassword
Параметр grailsApplication.config.testPassword доступен после инициализации приложения.