The <plugin> element is used to define a plugin. Plugins can be used to extend or modify the code generated by MyBatis Generator (MBG). This element is a child element of the <context> element. Any number of plugins may be specified in a context. The plugins will be called in the order that are listed in the configuration.
For more information about plugins, see the Implementing MyBatis Generator Plugins reference page.
MBG supplies several plugins (all are in the package
org.mybatis.generator.plugins
). The supplied plugins demonstrate
different types of tasks that can be accomplished with MBG plugins. Source
code for the plugins is available with the MBG downloads, or can be viewed
online
here.
Plugin | Description |
---|---|
(package).CaseInsensitiveLikePlugin |
This plugin adds methods to the Example class (actually to the Criteria inner class) to support case insensitive LIKE searches. This demonstrates adding functionality to the example classes via a plugin, rather than extending the class. |
(package).EqualsHashCodePlugin |
This plugin adds equals and hashCode methods to the
Java model objects generated by MBG.
The The |
(package).MapperConfigPlugin |
This plugin generates a skeleton MapperConfig.xml file that contains
references to the XML mapper files generated by MBG.
This file can be used to configure MyBatis 3.x environments.
This plugin accepts three properties:
Note: |
(package).RenameExampleClassPlugin |
This plugin demonstrates usage of the initialized method
by renaming the generated example classes generated by MBG.
This plugin accepts two properties:
For example, to rename the generated example classes from xxxExample to xxxCriteria, specify Example$ for searchString and Criteria for replaceString |
(package).SerializablePlugin |
This plugin adds the marker interface java.io.Serializable to the
Java model objects generated by MBG. This plugin also adds the
serialVersionUID field to the model classes.
Important: This is a simplistic implementation of java.io.Serializable and does not attempt to do any versioning of classes. |
(package).SqlMapConfigPlugin |
This plugin generates a skeleton SqlMapConfig.xml file that contains
references to the SqlMap.xml files generated by MBG.
This file can be used to configure iBATIS 2.x environments.
This plugin accepts three properties:
Note: |
Attribute | Description |
---|---|
type | The fully qualified name of the class that implements the plugin.
The class must implement the interface
org.mybatis.generator.api.Plugin ,
and must have a public default constructor. Note that it is far
easier to extend the adapter class
org.mybatis.generator.api.PluginAdapter
than to implement the entire interface. |
None