使用Properties文件配置实例的创建
2007-09-26 14:41
851 查看
目的在一个Properties文件中配置class的类路径,java程序中不需要直接创建对象,而是根据properties配制的类路径进行实例化,优点在于可以在外界改变类的动态类型,应用场景是,面向接口编程中,接口的动态实现类转移到外部配置
Properties props=new Properties()
props.load(new FileInputStream("config.properties"));
String budinessClass=props.getProperty("business.class");
Business business=(Business)Class.forName(businessClass).newInstance();
Properties props=new Properties()
props.load(new FileInputStream("config.properties"));
String budinessClass=props.getProperty("business.class");
Business business=(Business)Class.forName(businessClass).newInstance();
相关文章推荐
- spring List,Set,Map,Properties,array的使用配置文件注入实例
- PowerShell入门教程之创建和使用配置文件实例
- spring List,Set,Map,Properties,array的使用配置文件注入实例
- 使用properties配置文件为javabean注入属性值
- 从零开始学JDBC--1.9 代码抽取--使用Properties读取配置文件
- Java使用配置文件(properties)简易教程
- 一步一个脚印学习WCF系列之WCF概要—WCF服务的创建与调用HelloWorld实例,通过配置文件方式(六)
- 7.7.1: Bean实例的创建方式及依赖配置---使用构造器创建Bean实例
- Spring 中使用jasypt对配置文件(.properties)中密码加密
- Spring学习笔记 在XML配置文件中使用properties文件的键值
- JDBC工具类抽取方法(使用properties配置文件)
- hibernate使用配置文件创建联合主键往MySQL数据库插入数据
- 使用OpenCV官方提供文件配置、静态编译并运行OpenCV-2.3.x/2.4.x实例
- idea 创建properties配置文件
- Spring配置文件中使用ref local与ref bean的区别. 在ApplicationResources.properties文件中,使用<ref bean>与<ref local>方法如下
- 实例讲解.NET中资源文件的创建与使用(转)
- 问题:使用java中properties加载配置文件
- 谈Java Properties配置文件, 是J2EE容器的命令行绑定, 还是使用Deploy自适应的绑定?
- Spring学习笔记 在XML配置文件中使用properties文件的键值
- Spring中配置文件(properties)的读取与使用