spring引入属性文件

<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


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容