|
generatorConfig.xml
[html] view plaincopy
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE generatorConfiguration
- PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
- "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
-
- <generatorConfiguration>
- <classPathEntry
- location="C:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.18\mysql-connector-java-5.1.18.jar" />
- <!-- MyBatis3,Ibatis2Java5 -->
- <context id="DB2Tables" targetRuntime="MyBatis3">
- <!-- <plugin type="org.leef.db.mybatis.plugin.PaginationPlugin" /> -->
-
- <commentGenerator>
- <property name="suppressDate" value="true" />
- <property name="suppressAllComments" value="true" />
- </commentGenerator>
-
- <jdbcConnection driverClass="com.mysql.jdbc.Driver"
- connectionURL="jdbc:mysql://localhost/ManagerPlatform" userId="root"
- password="123456">
- </jdbcConnection>
-
- <javaTypeResolver>
- <property name="forceBigDecimals" value="false" />
- </javaTypeResolver>
-
- <javaModelGenerator targetPackage="com.bingya.model"
- targetProject="src/main/java">
- <property name="enableSubPackages" value="true" />
- <property name="trimStrings" value="true" />
- </javaModelGenerator>
-
- <sqlMapGenerator targetPackage="com.bingya.dao"
- targetProject="src/main/java">
- <property name="enableSubPackages" value="true" />
- </sqlMapGenerator>
-
- <javaClientGenerator type="XMLMAPPER"
- targetPackage="com.bingya.dao" targetProject="src/main/java">
- <property name="enableSubPackages" value="true" />
- </javaClientGenerator>
-
- <!-- <table tableName="T_Article" domainObjectName="Tarticle"> -->
- <!-- </table> -->
-
- <!-- <table tableName="T_Category" domainObjectName="TCategory"> -->
- <!-- </table> -->
-
- <!-- <table tableName="T_Asset" domainObjectName="Tasset"> -->
- <!-- </table> -->
-
- <table tableName="users" domainObjectName="Users">
- </table>
-
- <table tableName="authorities" domainObjectName="Authorities">
- </table>
-
- </context>
- </generatorConfiguration>
[html] view plaincopy
- import java.io.File;
- import java.io.IOException;
- import java.sql.SQLException;
- import java.util.ArrayList;
- import java.util.List;
-
- import org.mybatis.generator.api.MyBatisGenerator;
- import org.mybatis.generator.config.Configuration;
- import org.mybatis.generator.config.xml.ConfigurationParser;
- import org.mybatis.generator.exception.InvalidConfigurationException;
- import org.mybatis.generator.exception.XMLParserException;
- import org.mybatis.generator.internal.DefaultShellCallback;
-
- public class MBGenerator {
-
- /**
- * @param args
- * @throws XMLParserException
- * @throws IOException
- * @throws InvalidConfigurationException
- * @throws InterruptedException
- * @throws SQLException
- */
- public static void main(String[] args) throws IOException,
- XMLParserException, InvalidConfigurationException, SQLException,
- InterruptedException {
- List<String> warnings = new ArrayList<String>();
- boolean overwrite = true;
- File directory = new File(".");
- File configFile = new File(directory.getCanonicalPath()
- + File.separator + "src" + File.separator
- + "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);
- System.out.println("success");
- }
-
- }
|
|
|