Running MyBatis Generator with Eclipse

Installing the Eclipse Feature

The eclipse feature can be installed in any of the following ways:

  • Search for "MyBatis Generator" in the Eclipse marketplace and install directly from the marketplace. You can access the eclipse marketplace in two ways:
    1. Take the menu option Help>Eclipse Marketplace... in a running eclipse instance
    2. Go to https://marketplace.eclipse.org/
  • Manually configure an update site that points to https://dl.bintray.com/mybatis/mybatis-generator
  • Download the zipped eclipse update site from the GitHub release page (https://github.com/mybatis/generator/releases), unzip, and configure an update site that points to your unzipped directory.

Using the Eclipse Feature

To get up and running quickly with MyBatis Generator in the eclipse environment, follow these steps:

  1. Create a configuration file:
    1. File>New>Other...
    2. Select "MyBatis Generator Configuration File" from the "MyBatis" category, then press "Next"
    3. Specify the location of the file, and the name of the file (defaults to generatorConfig.xml)
    4. Finish the wizard
  2. Fill out the configuration file appropriately. At a minimum, you must specify:
    1. jdbcConnection information to specify how to connect to the target database
    2. A target package, and target project for the javaModelGenerator
    3. A target package, and target project for the sqlMapGenerator
    4. A target package, target project, and type for the javaClientGenerator (or you can remove the javaClientGenerator element if you don't wish to generate Java Clients)
    5. At least one database table
  3. Save the file
  4. Right click on the configuration file in Eclipse's navigator, or package explorer, view and take the menu option "Run As>Run MyBatis Generator"

Important Note: MyBatis Generator in eclipse will not overwrite any custom changes you make to the objects it generates. You can run it over and over again without fear of losing custom changes.