like title, when execute mybatis-generator, want overwriting generated *mapper.xml all, not merge! try many config way, doesn't implement correct. , everytime generator more once xml content. this:
<resultmap id="baseresultmap" type="com.test.entity.goodsentity"> ... <resultmap id="baseresultmap" type="com.test.entity.goodsentity"> ... <resultmap id="baseresultmap" type="com.test.entity.goodsentity"> ...
in properties, had add line:
<mybatis.generator.overwrite>true</mybatis.generator.overwrite>
and in build > plugin, add below lines:
<plugin> <groupid>org.mybatis.generator</groupid> <artifactid>mybatis-generator-maven-plugin</artifactid> <version>1.3.5</version> <configuration> <verbose>true</verbose> <overwrite>true</overwrite> <configurationfile>${mybatis.generator.configurationfile}</configurationfile> </configuration> <executions> <execution> <id>generate mybatis artifacts</id> <goals> <goal>generate</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupid>com.test</groupid> <artifactid>ob-maven-plugin-mybatis-generator</artifactid> <version>1.0</version> </dependency> </dependencies> </plugin>
in mybatis-generator.xml, try overwrite config yet. config doesn't work goo.
how modify configuration?
i able around creating plugin , adding mybatis-generator-config.xml file. note, of course, solution cause mapper.xml files overwritten regardless of whether or not -overwrite flag specified.
mybatis-generator-config.xml:
<generatorconfiguration> ... <context id="mycontextid"> <plugin type="com.mydomain.deleteexistingsqlmapsplugin"></plugin> ... </context> </generatorconfiguration>
deleteexistingsqlmapsplugin.java:
... public class deleteexistingsqlmapsplugin extends pluginadapter { @override public boolean validate(list<string> warnings) { return true; } @override public boolean sqlmapgenerated(generatedxmlfile sqlmap, introspectedtable introspectedtable) { string sqlmappath = sqlmap.gettargetproject() + file.separator + sqlmap.gettargetpackage().replaceall("\\.", file.separator) + file.separator + sqlmap.getfilename(); file sqlmapfile = new file(sqlmappath); sqlmapfile.delete(); return true; } }
this works because sqlmapgenerated() called after mapper.xml file created in memory before written disk.
Comments
Post a Comment