mybatis逆向工程

2023-03-14 15:44:03 浏览数 (1)

jar包

log4j-1.2.16.jar:日志包

mybatis-3.2.3.jar:mybatis包

mybatis-generator-core-1.3.2.jar:逆向工程包

mysql-connector-java-5.1.28-bin.jarjava连接mysql包

配置文件xxx.xml

logo4j.properties:

代码语言:javascript复制
log4j.rootLogger=DEBUG, Console
 Console
 log4j.appender.Console=org.apache.log4j.ConsoleAppender
 log4j.appender.Console.layout=org.apache.log4j.PatternLayout
 log4j.appender.Console.layout.ConversionPattern=%d [%t] %-5p [%c] - %m%n
 log4j.logger.java.sql.ResultSet=INFO
 log4j.logger.org.apache=INFO
 log4j.logger.java.sql.Connection=DEBUG
 log4j.logger.java.sql.Statement=DEBUG
 log4j.logger.java.sql.PreparedStatement=DEBUG
java代码
代码语言:javascript复制
public void Generator()throws Exception
{
     List<String> warnings = new ArrayList<String>();
       boolean overwrite = true;
       File configFile = new File("generatorConfig.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);
}

public static void main(String[] args)
{
    GeneratorMybatis generatorMybatis =  new GeneratorMybatis();
    try
    {
        generatorMybatis.Generator();
    } catch (Exception e)
    {
        e.printStackTrace();
    }
}

结构

0 人点赞