当前位置: 首页 > 知识库问答 >
问题:

如何解决生命周期配置未涵盖的插件执行:org。科德豪斯。mojo:exec maven-插件:1.5.0:exec?

朱俊雅
2023-03-14

我使用maven将角应用程序与java结合起来。POM的一部分看起来像这样

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.5.0</version>
            <executions>
                <execution>
                    <id>exec-npm-install</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <workingDirectory>${project.basedir}/src/main/angular-app</workingDirectory>
                        <executable>npm.cmd</executable>
                        <arguments>
                            <argument>install</argument>
                        </arguments>
                    </configuration>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
                <execution>
                    <id>exec-npm-ng-build</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <workingDirectory>${project.basedir}/src/main/angular-app</workingDirectory>
                        <executable>ng.cmd</executable>
                        <arguments>
                            <argument>build</argument>
                            <argument>--base-href=/testangularmaven/src/main/webapp/angular_build/</argument>
                        </arguments>
                    </configuration>
                    <goals>
                        <goal>exec</goal>
                    </goals>

                </execution>

            </executions>
        </plugin>       

mvn包运行良好,项目在war文件中编译,但eclipse表示pom不正确。使用标签的解决方案pluginManagement不匹配,因为它不会执行命令。如何解决eclipse的问题?

共有1个答案

督冠玉
2023-03-14

通过映射解决

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
    <pluginExecutions>
        <pluginExecution>
            <pluginExecutionFilter>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <versionRange>[1.5.0,)</versionRange>
                <goals>
                    <goal>exec</goal>
                </goals>
            </pluginExecutionFilter>
            <action>
                <execute />
            </action>
        </pluginExecution>
    </pluginExecutions>
</lifecycleMappingMetadata>
 类似资料: