Skip to main content
 首页 » 编程设计

避免maven package 打包时执行 mybatis-generator-maven-plugin 插件

2022年07月18日35shihaiming

一、为什么打包时会执行该插件
mybatis-generator-maven-plugin默认绑定了package的生命周期

二、如何解决
如果在package和install 执行插件,修改pom中的配置(黄色部分是修改后的部分,注释部分是之前的,之前的mvn打包有问题)

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>mybatis-generator</id>-->
<!-- <goals>-->
<!-- <goal>generate</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<!--<phase>package</phase>-->
<phase>deploy</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

本文参考链接:https://www.cnblogs.com/maohuidong/p/11507256.html