美文网首页
spring引入属性文件

spring引入属性文件

作者: 一脸茫然的小瑞君 | 来源:发表于2017-06-15 21:17 被阅读24次

<bean class="org.springframework.bean.factory.config.PropertyPlaceholderConfigure"

   p:location="classpath:com/xx/x/jdbc.properties"

   p:fileEncoding="utf-8"/>

<context:property-placeholder location="classpath:com/xx/x/jdbc.properties"/>

如果需要配置编码不可以直接设置file-encoding="uft-8", 会报错!!!

正确配置如下:

<bean id="utf8" class="java.lang.String">

   <constructor-arg value="utf-8"></constructor>

</bean>

<context:property-placeholder location="classpath:com/xx/x/jdbc.properties"

   file-encoding="utf8"/>

**在属性文件中如果属性值 太长 ,  可以在行后添加"\"分行

例如:在jdbc.properties中

password=a123456789qewrryurtyi\

sdfsnsgsvgertneesrteshsdtertsdgae

相关文章

网友评论

      本文标题:spring引入属性文件

      本文链接:https://www.haomeiwen.com/subject/obiuqxtx.html