如何使用系统属性加载属性文件

时间:2021-10-02 13:14:11

I have a properties file which sits on APPSERVERS HOME directory(JBOSS_HOME/PROJECT_PROPERTIES/abc.properties).PROJECT_PROPERTIES is the directory where we are keeping all the project related property files.I need to read this properties file from spring config.Earlier i was using the following approach.

我有一个属性文件,它位于APPSERVERS HOME目录(JBOSS_HOME / PROJECT_PROPERTIES / abc.properties).PROJECT_PROPERTIES是我们保存所有项目相关属性文件的目录。我需要从spring config读取这个属性文件。早先我是使用以下方法。

<bean id="propertyOverrideConfigurer"
        class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
        <property name="location" value="classpath:abc.properties" />

Now we moved all our properties file to JBOSS_HOME/PROJECT_PROPERTIES directory.

现在我们将所有属性文件移动到JBOSS_HOME / PROJECT_PROPERTIES目录。

Please provide me some pointers how to access the properties file using spring.

请给我一些指示如何使用spring访问属性文件。

2 个解决方案

#1


0  

This should help you out:

这应该可以帮到你:

How to read properties in spring

如何在春天阅读属性

#2


0  

You can pass the properties file path as a command line argument

您可以将属性文件路径作为命令行参数传递

<property name="location" value="${propertiesFile}" />

Then for the jvm parameters pass

然后为jvm参数传递

-DpropertiesFile=my/configuration/file.properties

#1


0  

This should help you out:

这应该可以帮到你:

How to read properties in spring

如何在春天阅读属性

#2


0  

You can pass the properties file path as a command line argument

您可以将属性文件路径作为命令行参数传递

<property name="location" value="${propertiesFile}" />

Then for the jvm parameters pass

然后为jvm参数传递

-DpropertiesFile=my/configuration/file.properties