generator作用: 根据表帮你生成实体类,和dao和xml映射文件。就是简单的CRUD。
官网:MyBatis Generator Core – Introduction to MyBatis Generator/
二、generator的使用1.导入mybatis-generator的依赖jar包。
org.mybatis.generator mybatis-generator-core1.4.0
2.创建配置文件
3.开始配置generator.xml文件
4、运行已经配置的generator.xml文件
可以在主方法中也可以在@Test单元测试中运行
public void crud_student()throws Exception{
List warnings = new ArrayList();
boolean overwrite = true;
File configFile = new File("generator.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);
}



