Mybatis3generatorsqlserver configuration explanation and application tool download

Source: Internet
Author: User
This is the mybatis3generator configuration file, including the main configuration parameters. For specific configuration instructions, please download the complete configuration application at the end of the article. An application is a java application based on myeclipse. In this article, MBG refers to the MybatisGenerator tool .? Xmlversion1.0encodingUTF-8 ?! DOCTYPEgeneratorConf

This is the mybatis3 generator configuration file, including the main configuration parameters. For specific configuration instructions, please download the complete configuration application at the end of the article. An application is a java application based on myeclipse. In this article, MBG refers to the MybatisGenerator tool. ? Xml version = 1.0 encoding = UTF-8? ! DOCTYPE generatorConf

This is the mybatis3 generator configuration file, including the main configuration parameters. For specific configuration instructions, please download the complete configuration application at the end of the article.

An application is a java application based on myeclipse.

In this article, MBG refers to the MybatisGenerator tool.

















ConnectionURL = "$ {connectionURL }"
UserId = "$ {userId}" password = "$ {password}"/>

















Because the mybatis plug-in can be run only when eclipse3.6 or above is required, run in cmd mode and double-click it in. bat mode.

We strongly recommend that you set each path in the property file to an absolute path, but not a package.

If you want to use it, modify properties The specific path of the property file.

Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------

The above command uses the cmd command to run mybatis generator. In fact, apache provides a more convenient method. That is, the main entry of the java file is supported to read the Generator configuration file.

The following is its code:

Package util; 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 MyBatisGeneratorTool {public static void main (String [] args) {List
 
  
Warnings = new ArrayList
  
   
(); Boolean overwrite = true; // whether to overwrite the original file String genCfg = "/generatorConfig. xml "; // configuration File name: File configFile = new File (MyBatisGeneratorTool. class. getResource (genCfg ). getFile (); // use the loader of the current class MyBatisGeneratorTool to load. Note that the path is java project name/bin/as the root path System. out. println (configFile. getAbsolutePath (); ConfigurationParser cp = new ConfigurationParser (warnings); Configuration config = null; try {config = cp. parseConfiguration (configFile);} catch (IOException e) {e. printStackTrace ();} catch (XMLParserException e) {e. printStackTrace ();} callback = new callback (overwrite); MyBatisGenerator myBatisGenerator = null; try {myBatisGenerator = new MyBatisGenerator (config, callback, warnings);} catch (InvalidConfigurationException e) {e. printStackTrace ();} try {myBatisGenerator. generate (null);} catch (SQLException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} catch (InterruptedException e) {e. printStackTrace ();}}}
  
 


This is more simple and convenient.

Problem Found: If a table is generated multiple times, the mapper. xml table will not be overwritten, but will be appended. Therefore, remember to delete the mapper. xml file of the corresponding table every time the front line is generated. Other generated files do not have this problem.

Certificate ---------------------------------------------------------------------------------------------------------------------------------------------

Mybatis generator automatically generates pages:

The project has integrated the paging plug-in. When the tool is generated, the page content is added to the corresponding mapper. xml file, and the selectByPage method is appended to mapper. java.

In fact, compared with the original generation result, it is only added to the mapper. xml file:

     
    
   
       
       
    
     
       and   
    
  
        where   
     
   
       
       
    
     
     
     
  
       order by ${orderByClause}   
     
   
        
  
       order by ${orderByClause}   
     
       select a.* from base_user a where a.user_id in  (select top ${pageSize} user_id from base_user  user_id not in (select top ${skipRecordCount} user_id from base_user    )   )  


The mybatis generation tool is a Java application in myeclipse:

Http://115.com/file/be93a63d test passed !!!.

Mybatis3 generator official documentation

Http://www.mybatis.org/generator/index.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.