爱游戏全站app官网入口-爱游戏官网

mybatis generator逆向工程的使用 -爱游戏全站app官网入口

2023-08-21,,

一.在 idea 中使用 mybatis generator

1.在idea上创建maven工程。

2.在pom.xml中配置mybatis逆向工程插件



org.mybatis.generator
mybatis-generator-maven-plugin
1.3.

true
true

3..配置generatorconfig.xml;


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/e3mall"
userid="root"
password="root">




targetproject="/users/mryuan/ideaprojects/creditrouter-tyr/onlineshop/onlineshop-mybatis-generator/src/main/java">






targetproject="/users/mryuan/ideaprojects/creditrouter-tyr/onlineshop/onlineshop-mybatis-generator/src/main/java">




targetpackage="com.yp.manager.dao"
targetproject="/users/mryuan/ideaprojects/creditrouter-tyr/onlineshop/onlineshop-mybatis-generator/src/main/java">
















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{
list warnings = 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();
}
}
}

mybatis generator逆向工程的使用的相关教程结束。

网站地图