maven package打包時,會自動執行 mybatis-generator-maven-plugin 外掛,導致mapper對映檔案被追加而出現錯誤, 實體也會被覆蓋

qq_40641961發表於2020-04-07

**

解決辦法

       在pom.xml 中做以下設定:改成<phase>deploy</phase>
	<plugin>
                <!--Mybatis-generator外掛,用於自動生成Mapper和POJO-->
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.2</version>
                <configuration>
                    <!--配置檔案的位置-->
                    <configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
                    <verbose>true</verbose>
                    <overwrite>true</overwrite>
                </configuration>
                <executions>
                    <execution>
                        <id>Generate MyBatis Artifacts</id>
                        <phase>deploy</phase> 
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.mybatis.generator</groupId>
                        <artifactId>mybatis-generator-core</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                </dependencies>
    </plugin>


相關文章