我问了一个类似的问题,但根据回答,我做了一个糟糕的工作,描述了我后。我有一个spring 4 webapp从属性文件加载属性。我们在春天通过“$ {proper.name”}表达式来使用这些属性,并且通过在我们的一些类中注入一个属性对象。从数据库和属性弹出配置属性
我们希望将大部分属性移动到数据库表并使它们可以重新加载。但是,有些需要留在本地属性中,可能会覆盖数据库设置。这些也应该在应用程序运行后动态加载。
我知道,一旦某个特定的bean被注入,它将不会被重新加载,这与我无关,这取决于该模块的处理。但是我很难得到我想要的行为。特别是,我已经从apache commons配置中实现了一个AbstractConfiguration,以获得双重源代码并覆盖了我之后的版本。但是,虽然它用于注入属性对象,但使用“$ {prop.name}”加载的表达式完全不起作用。
我该如何让他们工作?我忽略了错误的东西吗?它只是一些配置细节?
<bean id="sysProperties" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="databaseConfigurator" />
<property name="targetMethod" value="getProperties"/>
</bean>
<bean id="databaseConfigurator" class="my.util.config.MyDatabaseConfigurator">
<property name="datasource" ref="dataSource" />
<property name="propertyFile" value="/WEB-INF/my.properties" />
<property name="applicationName" value="ThisApp" />
</bean>
<bean id="dbConfigFactory" class="org.apache.commons.configuration.ConfigurationConverter" factory-method="getProperties">
<constructor-arg ref="databaseConfigurator" />
</bean>
的可能的复制[在数据库中存储的属性,但是局部覆盖](http://stackoverflow.com/questions/35850768/store-properties-in-database-but-override-locally) – JEY
我不我想这是因为我问了这个问题,我想我的工作做得不好。这个问题的答复者被困在了jndi问题上,因为我在这个问题上过多地关注了这个问题。结果是我没有得到有用的答案。所以我改述了。 @JEY – user1187719