Spring提供了加载Properties文件的工具类:org.springframework.beans.factory.config.PropertyPlaceholderConfigurer。 在Spring容器启动时,使用内置bean对属性文件信息进行加载,在bean. ...
Spring提供了加载Properties文件的工具类:org.springframework.beans.factory.config.PropertyPlaceholderConfigurer。
在Spring容器启动时,使用内置bean对属性文件信息进行加载,在bean.
<!-- spring的属性加载器,加载properties文件中的属性 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>/WEB-INF/configInfo.properties</value> </property> <property name="fileEncoding" value="utf-8" /> </bean>
通过get方法获取对应的属性信息,优点是代码中使用方便,缺点是如果代码中需用到新的属性信息,需对ConfigInfo.java做相应的添加修改。
海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com
原标题:Spring 中使用Properties文件
关键词:Spring
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。