之前一直对apache的DbUtils很好奇,也很佩服其中的设计上的智慧。于是就自己模拟实现了一个更加简便的小框架。我们只需要在配置文件中写上数据库层面的连接信息,就可以随心所欲的实现自己的需求了。
设计思路
依赖
apache-commons-logging.jar
apache-commons-beanutils.jar
mysql-connector.jar
技术细节
其中最主要的是是使用了反射技术和泛型操作,实现了对bean对象的属性的解析以及实例化相关的bean对象。
public class Converter<T> {
public static <T> T convert2Bean