Create generator file

You can easily create Mybatis generator configuration file by following New → Mybatis → New Generator File:

new generator file

Attributes

The plugin will provide attributes auto-completion and inspections based on the generator file DTD and Mybatis official documents, auto-completion is context-aware and available for all attributes.

attributes auto completion

attributes inspection

Jdbc connection

You'll also get driver class and connection URL auto-completion while you're editing JDBC connection:

jdbc connection

Target package

The plugin associates targetPackage attribute with project package, so you'll get auto-completion and inspection on the fly:

target-package.gif

Target project

The plugin associates targetProject attribute with project directory, it's set as the current directory where generator file is located by default. This attribute will be ignored when running Mybatis generator because targetPackage takes care of everything. You should never pay much attention to target project.

Generate table tags

It's very easy to select the tables that you want to generate using intention action. This will list all data sources that you configured in IntelliJ. You can invoke intention action by using shortcut ⌥ + ↩ on Mac and Alt + ↩ on Windows:

select table intention action

Select the tables you want to generate from select tables dialog, corresponding tags will be generated in generator file after you click OK button:

select table

Edit table tags

You can edit the generated tags easily if you need to further customize them:

customize table tag

Context table from schema or tableName attribute in table tag will be overridden by runtimeSchema or runtimeTableName attribute in child property tag if it's present:

table override

We can see here that the lookup-strings for column attribute of columnOverride tag come from project table instead of blog_view table because the value of runtimeTableName attribute is project

External property completion

The plugin inserts } automatically when you type ${ and provides auto-completion based on existing external property names:

property completion

Coming soon: Remove inspection error if external property name is present.

Element inspections

There are many useful inspections and quick fixes available there while you're editing:

quick-fix.gif

Codes Magic © 2013-2018 · Terms