Mysql逆向工程的使用

Mysql逆向工程的使用

1.编写配置文件
编写头部


然后写

 <generatorConfiguration>
  <context id="testTables" targetRuntime="MyBatis3">
  <commentGenerator>
            
            <property name="suppressAllComments" value="true" />
        commentGenerator>
        
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://localhost:3306/taotao" userId="root"
            password="root">
        jdbcConnection>
        
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        javaTypeResolver>

        
        <javaModelGenerator targetPackage="com.taotao.pojo"
            targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
            
            <property name="trimStrings" value="true" />
        javaModelGenerator>
        
        <sqlMapGenerator targetPackage="com.taotao.mapper" 
            targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
        sqlMapGenerator>
        
        <javaClientGenerator type="XMLMAPPER"
            targetPackage="com.taotao.mapper" 
            targetProject=".\src">
            
            <property name="enableSubPackages" value="false" />
        javaClientGenerator>
        
        <table schema="" tableName="tb_content">table>
        <table schema="" tableName="tb_content_category">table>
        <table schema="" tableName="tb_item">table>
        <table schema="" tableName="tb_item_cat">table>
        <table schema="" tableName="tb_item_desc">table>
        <table schema="" tableName="tb_item_param">table>
        <table schema="" tableName="tb_item_param_item">table>
        <table schema="" tableName="tb_order">table>
        <table schema="" tableName="tb_order_item">table>
        <table schema="" tableName="tb_order_shipping">table>
        <table schema="" tableName="tb_user">table>

  context>
  generatorConfiguration>

固定写法

2.实现逆向生层
1.指定逆向工程配置文件
File configFile = new File(“generatorConfig.xml”);
2.配置解析
List waring = new ArrayList();
ConfigurationParser parser = new ConfigurationParser(waring);
3.配置文件
Configuration configuration = parser.parseConfiguration(configFile);
4.文件夹是否创建
DefaultShellCallback dsc = new DefaultShellCallback(true);
5.生成对象
MyBatisGenerator my= new MyBatisGenerator(configuration, dsc, waring);
6.生成
my.generate(null);

你可能感兴趣的:(分布式系统,mysql)