資源簡介
MyBatis的一個主要的特點就是需要程序員自己編寫sql,那么如果表太多的話,難免會很麻煩,所以mybatis官方提供了一個逆向工程,可以針對單表自動生成mybatis執(zhí)行所需要的代碼(包括mapper.xml、mapper.java、po..)。一般在開發(fā)中,常用的逆向工程方式是通過數(shù)據(jù)庫的表生成代碼。
代碼片段和文件信息
import?java.io.File;
import?java.util.ArrayList;
import?java.util.List;
import?org.mybatis.generator.api.MyBatisGenerator;
import?org.mybatis.generator.config.Configuration;
import?org.mybatis.generator.config.xml.ConfigurationParser;
import?org.mybatis.generator.internal.DefaultShellCallback;
public?class?GeneratorSqlmap?{
public?void?generator()?throws?Exception{
List?warnings?=?new?ArrayList();
boolean?overwrite?=?true;
//指定?逆向工程配置文件
File?configFile?=?new?File(“generatorConfig.xml“);?
ConfigurationParser?cp?=?new?ConfigurationParser(warnings);
Configuration?config?=?cp.parseConfiguration(configFile);
DefaultShellCallback?callback?=?new?DefaultShellCallback(overwrite);
MyBatisGenerator?myBatisGenerator?=?new?MyBatisGenerator(config
callback?warnings);
myBatisGenerator.generate(null);
}?
public?static?void?main(String[]?args)?throws?Exception?{
try?{
GeneratorSqlmap?generatorSqlmap?=?new?GeneratorSqlmap();
generatorSqlmap.generator();
}?catch?(Exception?e)?{
e.printStackTrace();
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-09-01?17:38??mybatisGeneratorCustom\
?????文件?????????542??2017-09-06?14:04??mybatisGeneratorCustom\.classpath
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\
?????目錄???????????0??2017-09-06?14:04??mybatisGeneratorCustom\.git\branches\
?????文件?????????264??2017-09-06?14:04??mybatisGeneratorCustom\.git\config
?????文件?????????127??2017-09-06?14:04??mybatisGeneratorCustom\.git\FETCH_HEAD
?????文件??????????23??2017-09-06?14:04??mybatisGeneratorCustom\.git\HEAD
?????目錄???????????0??2017-09-06?14:04??mybatisGeneratorCustom\.git\hooks\
?????文件????????1624??2017-09-06?14:04??mybatisGeneratorCustom\.git\index
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\logs\
?????文件?????????146??2017-09-06?14:04??mybatisGeneratorCustom\.git\logs\HEAD
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\logs\refs\
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\logs\refs\heads\
?????文件?????????146??2017-09-06?14:04??mybatisGeneratorCustom\.git\logs\refs\heads\master
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\logs\refs\remotes\
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\logs\refs\remotes\origin\
?????文件?????????160??2017-09-06?14:04??mybatisGeneratorCustom\.git\logs\refs\remotes\origin\master
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\ob
?????目錄???????????0??2017-09-06?14:04??mybatisGeneratorCustom\.git\ob
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\ob
?????文件????????2584??2017-09-06?14:04??mybatisGeneratorCustom\.git\ob
?????文件?????6092631??2017-09-06?14:04??mybatisGeneratorCustom\.git\ob
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\refs\
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\refs\heads\
?????文件??????????41??2017-09-06?14:04??mybatisGeneratorCustom\.git\refs\heads\master
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\refs\remotes\
?????目錄???????????0??2018-08-25?22:20??mybatisGeneratorCustom\.git\refs\remotes\origin\
?????文件??????????41??2017-09-06?14:04??mybatisGeneratorCustom\.git\refs\remotes\origin\master
?????目錄???????????0??2017-09-06?14:04??mybatisGeneratorCustom\.git\refs\tags\
?????文件?????????381??2017-09-06?14:04??mybatisGeneratorCustom\.project
?????目錄???????????0??2018-09-01?17:38??mybatisGeneratorCustom\.settings\
............此處省略16個文件信息
評論
共有 條評論