mybatis逆向工程工具类的使用---mybatis generator
项目结构
配置文件
1 2 56 7 8 459 11 1210 15 16 1718 20 21 2219 24 27 28 2925 26 30 32 33 3431 36 38 39 40 4137 42 44
测试工具类编写
1 package com.shao.test; 2 3 import java.io.File; 4 import java.util.ArrayList; 5 import java.util.List; 6 7 import org.mybatis.generator.api.MyBatisGenerator; 8 import org.mybatis.generator.config.Configuration; 9 import org.mybatis.generator.config.xml.ConfigurationParser;10 import org.mybatis.generator.internal.DefaultShellCallback;11 12 public class MBGTest {13 14 public static void main(String[] args) throws Exception {15 Listwarnings = new ArrayList ();16 boolean overwrite = true;17 File configFile = new File("mbg.xml");18 ConfigurationParser cp = new ConfigurationParser(warnings);19 Configuration config = cp.parseConfiguration(configFile);20 DefaultShellCallback callback = new DefaultShellCallback(overwrite);21 MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,22 callback, warnings);23 myBatisGenerator.generate(null);24 }25 }