SQLMapGenerator targetProject="\MyBatis Gen\src", The xml files are not appearing after the mybatis generator is ran.

228 views
Skip to first unread message

Ryan Conklin

unread,
Nov 12, 2012, 4:46:38 PM11/12/12
to mybati...@googlegroups.com
My xml config sheet as follows;


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
  PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
<generatorConfiguration>
        <classPathEntry location="C:\projects\lib\mybatis\mybatis-generator-core-1.3.2.jar" />

        <context id="MySQLTables" targetRuntime="MyBatis3">
                <!-- ???? ???? ?? ?? -->
                <commentGenerator>
                        <property name="suppressAllComments" value="true" />
                        <property name="suppressDate" value="true" />
                </commentGenerator>
               
                <!-- ?????? ???? -->
                <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://10.10.12.35:3306/" userId="jeremie"
                        password="jeremie">
                </jdbcConnection>

                <!-- ????? ?? ??? ??? ?? ???? ?? -->
                <javaTypeResolver>
                        <property name="forceBigDecimals" value="false" />
                </javaTypeResolver>

                <!-- ????? ????? ?? ???? ?? ?? -->
                <javaModelGenerator targetPackage="ldg.mybatis.model"  targetProject="mybatis_generator">
                        <!--property name="constructorBased" value="true" />
                        <property name="immutable" value="true" /-->
                        <property name="enableSubPackages" value="true" />
                        <property name="trimStrings" value="true" />
                </javaModelGenerator>

                <!-- ?? XML? ?? ?? -->
                <sqlMapGenerator targetPackage="test.xml" targetProject="\MyBatis Gen\src">
                        <property name="enableSubPackages" value="true" />
                </sqlMapGenerator>
               
                <!-- ?? XML? ?? ????? ?? ??, type?? ANNOTATEDMAPPER, MIXEDMAPPER, XMLMAPPER ? ??  -->
                <javaClientGenerator type="XMLMAPPER" targetPackage="test.dao"
                        targetProject="\MyBatis Gen\src">
                        <property name="enableSubPackages" value="true" />
                </javaClientGenerator>

                <!-- ???? ??? ?? -->
                <table schema="null" tableName="organization" domainObjectName="Comment">
                        <property name="useActualColumnNames" value="false" />
                        <property name="ignoreQualifiersAtRuntime" value="true" />
                        <generatedKey column="comment_no" sqlStatement="MySql" identity="true" type="post" />
                        <!--columnOverride column="DATE_FIELD" property="startDate" />
                        <ignoreColumn column="FRED" />
                        <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" / -->
                </table>
        </context>
</generatorConfiguration>




My code as follows;



/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mybatis.gen;

import com.sun.corba.se.impl.orb.ORBConfiguratorImpl;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import javax.security.auth.login.Configuration;
import org.mybatis.generator.api.MyBatisGenerator;
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;
import org.mybatis.generator.internal.util.ClassloaderUtility;


/**
 *
 * @author carl
 */
public class MyBatisGen {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)throws IOException, XMLParserException,  InvalidConfigurationException, SQLException,  InterruptedException, IllegalArgumentException{
        try {
            ArrayList<String> warnings = new ArrayList<String>();
            File file = new File("mybatisGEN.xml");
            System.out.println(file.getCanonicalPath());
            boolean overwrite = true;
            File configFile = new File("mybatisGEN.xml");
            ConfigurationParser cp = new ConfigurationParser(warnings);
            org.mybatis.generator.config.Configuration config = cp.parseConfiguration(configFile);
            DefaultShellCallback callback = new DefaultShellCallback(overwrite);
            MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
            myBatisGenerator.generate(null);
        }
        catch( Exception ex) {
            ex.printStackTrace();
        }
        
    }
}      
   

Jeff Butler

unread,
Nov 12, 2012, 9:30:57 PM11/12/12
to mybati...@googlegroups.com
My best guess is that the directory "\MyBatis Gen\src" doesn't exist.  You should print the warning messages after you call the generate() method - there's probably a warning message that will tell you what's going on.

Jeff Butler

Ryan Conklin

unread,
Nov 13, 2012, 10:34:46 AM11/13/12
to mybati...@googlegroups.com
I took your advise and printed the messages, they are as follows;

[Table configuration with catalog null, schema information_schema, and table organization did not resolve to any tables]
org.mybatis.generator.config.Configuration@f892a4
org.mybatis.generator.internal.DefaultShellCallback@1636e4e

However I am still not getting any xml mappings, even with a null value I should just get the whole table right?

Ryan Conklin

unread,
Nov 13, 2012, 1:54:37 PM11/13/12
to mybati...@googlegroups.com
I figured it out, it was related to the connectionURL. I had not given a complete path to the database I was attempting to access. Thanks Jeff for help thus far, I apologize for the newbie mistakes.
Reply all
Reply to author
Forward
0 new messages