场景:项目中使用了mybatis-generator插件,在使用mvn package命令打包时,mybatis-generator也会执行,导致在dao中自定义的函数被删除。
原因:是因为mybatis-generator插件默认绑定了package的生命周期
解决:在pom中手动设置一下mybatis-generator插件绑定的生命周期即可
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<phase>deploy</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>