【JAVA笔记——器】MyBatis映射以及DAO文件生成工具源码

写了一个工具类,根据Entity自动生成Mapper文件、Dao文件和Impl文件

现在只支持Maven_Web项目格式

LazyUtils utils = new LazyUtils (Entity.clas)

Entity Class需要4层目录结构 例如
com.cunchen.base.entity
对应 com.cunchen.子项目名.实体包

生成生成Dao及DaoImpl如下

/src/main/java
com.cunchen.base.dao
                    -BaseDao
                    -EntityDao

com.cunchen.base.dao.Impl
                    -BaseDaoImpl
                    -EntityDaoImpl

/src/main/resources
com.cunchen.base.mapper
                    -EntityMapper.xml

对应sqlSession注入名 sqlSessionForBase

之后会增加可配置扩展以及自动生成建表语句。

JAR包:链接:http://pan.baidu.com/s/1c2zABzM 密码:0mah

源码:链接:http://pan.baidu.com/s/1jHL2Nrw 密码:txbq

posted @ 2016-07-05 22:54  写昵称不如写代码  阅读(163)  评论(0编辑  收藏  举报