一.在 idea 中使用 mybatis generator 逆向工程
1.在IDEA上创建maven工程。
2.在pom.xml中配置MyBatis逆向工程插件
org.mybatis.generator mybatis-generator-maven-plugin 1.3.5 true true
3..配置generatorConfig.xml;
4.执行Java 类
package com.yp.manager;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;import java.io.File;import java.util.ArrayList;import java.util.List;/** * desc * * @Author 袁朋 * @Date 2019/3/5 */public class Generator { public void generator() throws Exception{ Listwarnings = new ArrayList (); boolean overwrite = true; /**指向逆向工程配置文件*/ File configFile = new File("/Users/mryuan/IdeaProjects/creditRouter-tyr/onlineShop/onlineShop-mybatis-generator/src/main/resources/generationConfig.xml"); ConfigurationParser parser = new ConfigurationParser(warnings); Configuration config = parser.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 { Generator generatorSqlmap = new Generator(); generatorSqlmap.generator(); } catch (Exception e) { e.printStackTrace(); } }}