Java:属性的具体配置位置?
在我的Java类中,使用Props.Java文件。 我有这个静态块,如图所示Java:属性的具体配置位置?,java,tomcat,properties,Java,Tomcat,Properties,在我的Java类中,使用Props.Java文件。 我有这个静态块,如图所示 static { instanceName = System.getProperty("bayer.instanceName"); systemPath = System.getProperty("bayer.home"); if (systemPath == null) systemPath = "."; propsFile = new File(System.getP
static
{
instanceName = System.getProperty("bayer.instanceName");
systemPath = System.getProperty("bayer.home");
if (systemPath == null)
systemPath = ".";
propsFile = new File(System.getProperty("bayer.home") + File.separator + "bayer.properties");
}
请告诉我该属性bayer.instanceName和bayer.home的定义位置??
有关更多信息,我正在使用Apache Tomcat 6.0服务器和Linux环境。在java命令行上使用
-Dpropertyname=value
语法设置系统属性,例如:
java -cp someclasspath -Dbayer.instanceName=foo com.mycompany.MyClass
有关更多信息,请参阅。另一个标准位置是
$TOMCAT_HOME/bin/setenv.sh
如果你在那里找不到它们,请执行grep bayer.home$TOMCAT_home/bin
另一个需要检查的资源是依赖于您的系统的init脚本。参见
/etc/init.d
我认为java-cp someclasspath-Dbayer.instanceName=foo com.mycompany.MyClass
是正确的。在您的情况下,-Dbayer.instanceName=foo
将被视为第一个系统参数hi,从链接中我发现这很有用,在操作系统中设置了环境变量,例如,在linux export HOME=/Users/myusername或windows SET WINDIR=C:\windows等中,但如何查看属性文件???@YYYYI777您的应用程序必须主动加载属性文件-它不是自动加载的。检查代码以确定正在加载哪些文件这是该文件的副本吗?