Java 服务器启动时如何在jboss tomcat struts中加载config.properties文件

Java 服务器启动时如何在jboss tomcat struts中加载config.properties文件,java,tomcat,jboss,properties,struts,Java,Tomcat,Jboss,Properties,Struts,我是JavaEE初学者。我正在尝试修改一个系统(jboss-3.2.3、tomcat-5.0.28、struts-1.1)。我需要在jboss/tomcat启动时加载一个config.properties文件,这样属性就可以用于整个应用程序 这就是我被要求做的:“第一次(仅一次)加载.properties,这样,当需要读取时,它已经在内存中了” 我该怎么做?我从哪里开始 编辑: 我正在尝试从properties-service.xml加载 <?xml version="1.0" encod

我是JavaEE初学者。我正在尝试修改一个系统(jboss-3.2.3、tomcat-5.0.28、struts-1.1)。我需要在jboss/tomcat启动时加载一个config.properties文件,这样属性就可以用于整个应用程序

这就是我被要求做的:“第一次(仅一次)加载.properties,这样,当需要读取时,它已经在内存中了”

我该怎么做?我从哪里开始

编辑: 我正在尝试从properties-service.xml加载

<?xml version="1.0" encoding="UTF-8"?>
<server>
    <mbean code="org.jboss.varia.property.PropertyEditorManagerService" name="jboss:type=Service,name=PropertyEditorManager"></mbean>

    <mbean code="org.jboss.varia.property.SystemPropertiesService" name="jboss:type=Service,name=SystemProperties">
        <attribute name="URLList">
            ./conf/somelocal.properties
        </attribute>
        <attribute name="Properties">
            my.project.property=This is the value of my property
            my.project.anotherProperty=This is the value of my other property
        </attribute>
    </mbean>
</server>
但当我尝试使用该属性时,返回null:

String myProperty = System.getProperty("my.project.property");
System.out.println(myProperty); // null
有什么问题吗?

请看下面的示例。配置位于/server//deploy/properties service.xml中。下面是一个例子:

<server>
    <mbean code="org.jboss.varia.property.SystemPropertiesService"
           name="jboss.util:type=Service,name=SystemProperties">

        <!-- Load properties from each of the given comma seperated URLs -->
        <attribute name="URLList">
            http://somehost/some-location.properties,
            ./conf/somelocal.properties
        </attribute>

        <!-- Set propertuies using the properties file style. -->
        <attribute name="Properties">
            property1=This is the value of my property
            property2=This is the value of my other property
        </attribute>

    </mbean>
</server>

http://somehost/some-location.properties,
./conf/somelocal.properties
property1=这是我的属性的值
property2=这是我的其他属性的值

我按照您的建议使用properties-service.xml,但有些东西失败了。知道吗?我没有任何错误信息。属性似乎加载正确(检查我原始问题中的更新部分),但我无法获取“urlist”或“properties”始终返回null加载的属性的值。我猜属性应该在任何jsp文件上都可用,对吗?
<server>
    <mbean code="org.jboss.varia.property.SystemPropertiesService"
           name="jboss.util:type=Service,name=SystemProperties">

        <!-- Load properties from each of the given comma seperated URLs -->
        <attribute name="URLList">
            http://somehost/some-location.properties,
            ./conf/somelocal.properties
        </attribute>

        <!-- Set propertuies using the properties file style. -->
        <attribute name="Properties">
            property1=This is the value of my property
            property2=This is the value of my other property
        </attribute>

    </mbean>
</server>