未使用grails应用程序中的classpath属性文件 [英] classpath property file in grails app is not being used
问题描述
我的问题是我在我的类路径中放置了一个格式良好的属性文件,并告诉grails在我的类路径中查找属性文件,但是文件中的属性并未覆盖现有的属性。
在我的config.groovy中,我有几行:
grails.config。 locations = [classpath:$ {appName} -config.properties,
file:./$ {appName} -config.properties]
//验证appName正在用过的。如预期的那样,它打印出类路径:XXX-config.properties,其中XXX是我的应用程序名称。
printlngrails.config.locations:$ {grails.config.locations}
在我的XXX-config.properties中,我指定了一个不同的数据库连接URL(这是我想使用的):
dataSource.url = jdbc:postgresql://products.yyyyy.ap-southeast-1.rds.amazonaws.com:5432 / mydatabasename
然后我将XXX-config.properties放入我的类路径并启动tomcat7,但是引发错误,说它找不到我故意假的数据库,这意味着数据库属性没有被覆盖。
现在我想我的类路径是错误的,但是我做了 ps aux | grep tomcat
它告诉我,tomcat7的命令行arg包含-classpath:/ home / jbu /:_ other_paths_here_。注意我把我的属性文件放在/home/jbu/XXX-config.properties。
所以classpath dir看起来是正确的,所以现在我想也许是我的属性文件的格式不正确,所以我在我的grails.config.locations中添加了一个硬链接的file:/home/jbu/XXX-config.properties,并且找到了这些属性并成功重写,这意味着属性没有任何问题文件本身。
我在这里没有更多的想法。有人可以帮助我吗?
旁注:我通过将此行添加到/ usr / share来修改tomcat7的CLASSPATH变量/tomcat7/bin/setenv.sh:
export CLASSPATH =$ {CLASSPATH}:/ home / jbu /
在Grails中,被打破。叹息...我使用的是grails 2.4.5,所以我有点惊讶它自1.3.5以来已经被破解。
http://jay-chandran.blogspot.com/2010/10/ grails-using-external-properties-file.html
Grails 1.3.5:如何配置Datasource.groovy以连接到MySQL或SQL Server
My problem is that I've put a well-formed properties file in my classpath and told grails to look for the properties file in my classpath, but the properties in the file aren't overriding the existing ones.
In my config.groovy I have the lines:
grails.config.locations = [ "classpath:${appName}-config.properties",
"file:./${appName}-config.properties"]
// verified that appName is being used. It prints out classpath:XXX-config.properties, as expected, where XXX is my appname.
println "grails.config.locations: ${grails.config.locations}"
In my XXX-config.properties, I specify a different DB connection URL (this is the one I want to use):
dataSource.url=jdbc:postgresql://products.yyyyy.ap-southeast-1.rds.amazonaws.com:5432/mydatabasename
Then I put the XXX-config.properties in my classpath and startup tomcat7, but the errors are thrown, saying it can't find my deliberately fake db, meaning the database property did not get overridden.
Now I'm thinking my classpath is wrong, but I do ps aux | grep tomcat
which tells me that the command line arg for tomcat7 contains " -classpath :/home/jbu/:_other_paths_here_". Note I put my properties file at /home/jbu/XXX-config.properties. I am slightly concerned about that leading colon, but it doesn't seem to cause any other problems.
So the classpath dir appears correct, so now I thought maybe my properties file isn't properly formatted, so I added a harded "file:/home/jbu/XXX-config.properties" to my grails.config.locations, and the properties were found and successfully overridden, meaning nothing is wrong with the properties file itself.
I don't have any more ideas here. Can someone help me out?
Sidenote: I modified the CLASSPATH variable for tomcat7 by adding this line to /usr/share/tomcat7/bin/setenv.sh:
export CLASSPATH="${CLASSPATH}:/home/jbu/"
This (among with many other things in Grails, it seems) is broken. Sigh...I'm using grails 2.4.5 so I'm a bit surprised that it has been broken since 1.3.5.
http://jay-chandran.blogspot.com/2010/10/grails-using-external-properties-file.html
Grails 1.3.5: How to configure Datasource.groovy to either connect to MySQL or SQL Server
这篇关于未使用grails应用程序中的classpath属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!