我想要根据属性file.how的请求获取特定值来执行此操作?
我有以下spring配置。我想根据请求设置Exprops的值,并从属性文件中获取相应的值
<bean id="Prop" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:ErrorMessage.properties</value>
</property>
</bean>
<bean id="PropertiesBean" class="com.util.PropertiesUtil">
<property name="Exprops" value="${EXampleExceptiion}"></property>
</bean>
发布于 2011-04-15 07:31:34
使用PropertiesFactoryBean在Bean中注入Properties。
<bean id="myPropertiesBean"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:ErrorMessage.properties"/>
</bean>
这提供了一个Properties对象/ Bean,可以在任何Bean (<property name="x" ref="myPropertiesBean"/>
)中以myPropertiesBean
的名称注入。
此外,Spring提供了PropertyFactoryBean名称空间(从Spring2.5开始):在那里,您可以编写更短的util定义:
<util:properties id="myPropertiesBean"
location="classpath:ErrorMessage.properties"/>
发布于 2012-07-01 18:59:09
所有人都使用以下编程方式来完成此操作
XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("beans.xml"));
PropertyPlaceholderConfigurer cfg = new PropertyPlaceholderConfigurer();
cfg.setLocation(new FileSystemResource("jdbc.properties"));
cfg.postProcessBeanFactory(factory);
发布于 2018-07-06 04:49:26
<util:properties id="" location="location of prop file" />
此返回java.util.Properties对象
https://stackoverflow.com/questions/5665296
复制相似问题