1/自动生成的jar包:mybatis-generator-core-1.3.2.jar
2/generatorconfig.xml文件如:
/p>
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
connectionURL="jdbc:mysql://localhost:3306/abcProject?characterEncoding=utf8" userId="root"
password="11112222">
targetProject="D:estxmlParer">
targetProject="D:estxmlParer">
targetPackage="xmlParer"
targetProject="D:estxmlParer">
3.1/ 执行命令
java -jar mybatis-generator-core-1.3.0.jar -configfile D:estgeneratorconfig.xml -overwrite
这样基本就ok了。
3.2 Main方法执行
List warnings = new ArrayList();
boolean overwrite = true;
File configFile = new File("src/generatorConfig.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config;
try {
config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator;
try {
myBatisGenerator = new MyBatisGenerator(config, callback,
warnings);
myBatisGenerator.generate(null);
} catch (Exception e) {
e.printStackTrace();
}