Spring中加载属性文件
来源:互联网 发布:pop字体软件下载 编辑:程序博客网 时间:2024/05/01 04:21
在SPRING中提供了一个专门加载属性文件的类,我们只要给它指定属性文件所在的路径即可。这样我们就可以把一些经常变化的配置放入特定的属性文件中。下面为该类在SPRING中的配置:
- <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="location">
- <value>classpath:com/starxing/test/database.properties</value>
- </property>
- <!-- 使用locations属性定义多个配置文件
- <property name="locations">
- <list>
- <value>classpath:config/mail.properties</value>
- <value>classpath:config/database.properties</value>
- </list>
- </property>
- -->
- </bean>
- <bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="url">
- <value>${database.url}</value>
- </property>
- <property name="driverClassName">
- <value>${database.driver}</value>
- </property>
- <property name="username">
- <value>${database.user}</value>
- </property>
- <property name="password">
- <value>${database.password}</value>
- </property>
- </bean>
database.properties
database.driver=org.postgresql.Driver
database.url=jdbc:postgresql://localhost/test
database.user=postgres
database.password=123456
propertyConfigurer加载database.properties文件,为创建dataSource提供参数。
- Spring中加载属性文件
- Spring中加载属性文件
- 将属性文件加载道spring容器中
- spring加载java属性文件
- spring的属性加载器,加载properties文件中的属性
- Spring 中加载资源文件
- Spring 中加载资源文件
- Spring 中加载资源文件
- spring中加载properties文件
- Spring中外部属性文件
- spring+mybatis 注入properties文件中属性失败导致datasource加载失败的原因和解决
- 加载spring信息,属性文件信息,注册proxool
- spring配置文件加载FTP服务器上的属性文件
- 关于spring没有加载属性文件的问题
- Spring-----多环境中加载资源配置文件
- Spring配置中引用外部属性文件
- spring中属性文件properties的读取
- Spring 中如何使用外部属性文件
- 六章
- 管理信息系统的三种模式
- 什么是程序员的优秀品质?
- 少年总裁张伯宏
- 插入U盘后wince有可能关不了机
- Spring中加载属性文件
- 静态控件(static)
- 基于IO Packet隐藏文件和注册表,过磁盘解析和总线解析
- 承接jsp网页项目
- C语言中关键词 "int 数的范围为-32 768~32 767"是什么意思
- 如何学好C语言
- c语言的问题
- 谢啦 哪本c语言教材好啊
- 用C#实现字符串的逆序输出 急