开发者

Java and environment variables on Windows

I use:

<context:property-placeholder loca开发者_开发问答tion="file:${PROJECT_CONFIG_PATH}/project.conf" />

in my applicationContext.xml to get local config (one for development and another for production). PROJECT_CONFIG_PATH is a system environment variable (not eclipse env).

It works: on Windows in Eclipse (Jetty) and on Unix.

It doesn't work: on Windows with Tomcat 6 (java.io.FileNotFoundException: ${PROJECT_CONFIG_PATH}\project.conf)

Could someone please tell me why Tomcat on Windows doesn't see environment variables? And how could this be solved?

Thanks in advance!


If Tomcat is being run as a service, you will need to use the tomcat configuration editor to set the variable.

Start->Programs->Apache Tomcat x.x->Configure Tomcat

Select the Java tab Add the variable under "Java Options" as:

-DPROJECT_CONFIG_PATH="c:/yourpath"

Click OK and then restart the tomcat service.


Try this ...

<context:property-placeholder location="classpath:/PROJECT_CONFIG_PATH/project.conf" />


I don't think Tomcat's startup batch files inherit the parent environment. Not sure why, though.

Try setting PROJECT_CONFIG_PATH in either catalina.bat or startup.bat in the Tomcat bin directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜