spring+junit4+注解方式PropertiesFactoryBean读取properties
来源:互联网 发布:上饶程序员 编辑:程序博客网 时间:2024/06/08 11:32
下载链接地址
http://pan.baidu.com/s/1bonE9Uf
db.properties
jdbc.username=rootjdbc.password=rootjdbc.driverClass=com.mysql.jdbc.Driverjdbc.jdbcUrl=jdbc:mysql:///db_bookjdbc.initPoolSize=5jdbc.maxPoolSize=10
JDBCProperties
package com.konglingfu.propertiesDemo;import org.springframework.beans.factory.annotation.Value;public class JDBCProperties { @Value("#{configProperties['jdbc.username']}") private String userName; @Value("#{configProperties['jdbc.jdbcUrl']}") private String jdbcUrl; @Value("#{configProperties['jdbc.password']}") private String password; @Value("#{configProperties['jdbc.driverClass']}") private String driverClass; @Value("#{configProperties['jdbc.initPoolSize']}") private String initPoolSize; @Override public String toString() { return "JDBCProperties [userName=" + userName + ", jdbcUrl=" + jdbcUrl + ", password=" + password + ", driverClass=" + driverClass + ", initPoolSize=" + initPoolSize + "]"; }}
import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import com.konglingfu.propertiesDemo.JDBCProperties;@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = "classpath:applicationContext.xml")public class PropertiesTest extends AbstractJUnit4SpringContextTests { @Autowired private JDBCProperties jdbcProperties; @Test public void testPrintProperties(){ String result = jdbcProperties.toString(); System.out.println(result); }}
输出结果
JDBCProperties [userName=root, jdbcUrl=jdbc:mysql:///db_book, password=root, driverClass=com.mysql.jdbc.Driver, initPoolSize=5]
0 0
- spring+junit4+注解方式PropertiesFactoryBean读取properties
- Spring读取properties:PropertiesFactoryBean和PropertyPlaceholderConfigurer
- spring注解方式读取properties文件中值
- spring注解的方式读取properties文件中的内容
- Spring读取properties方式
- spring利用PropertiesFactoryBean管理属性配置文件properties
- Spring 注解方式集成 Junit4 进行单元测试
- spring使用注解@Value读取.properties文件
- spring管理属性配置文件properties——使用PropertiesFactoryBean
- spring管理属性配置文件properties——使用PropertiesFactoryBean
- spring管理属性配置文件properties——使用PropertiesFactoryBean
- spring junit4 注解测试
- spring相关JUnit4注解
- Spring使用程序方式读取properties文件
- Spring使用程序方式读取properties文件
- Spring 读取properties文件key+value方式
- 使用spring注解方法读取properties文件中值
- Spring MVC 通过@Value注解读取.properties配置
- 在Dialog中button与回车键
- html页面自动滚动
- hdoj-1026--Ignatius and the Princess I---BFS+优先队列(每次先用用时最少的点进行扩展)【A*】
- 网络IO,阻塞,非阻塞,异步,同步io的总结
- BZoj 2463: [中山市选2009]谁能赢呢?【博弈】
- spring+junit4+注解方式PropertiesFactoryBean读取properties
- C# ListView用法详解
- char、short int long 数据类型 区别
- 智络店+会员管理系统3.2版本耀世登场
- ArcGIS教程:地理处理服务示例(分水岭)(二)
- 姿态解算
- Linux常用命令
- 最小环 hdu1599 Floyd算法
- TextView加边框