Java – why Maven war plugin failed web XML fails if I configure it without failing in the missing web xml?

This is a challenge: Why did this build fail?

I have configured Maven's Maven war plugin, which will not be in a missing web Failed in XML file as if:

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <executions>
            <execution>
                <id>prepare-war</id>
                <phase>prepare-package</phase>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archiveClasses>false</archiveClasses>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix />
                        </manifest>
                        <manifestEntries>
                            <Implementation-Build>${build.number}</Implementation-Build>
                            <Implementation-Title>${project.name}</Implementation-Title>
                            <Built-By>${user.name}</Built-By>
                            <Built-OS>${os.name}</Built-OS>
                            <Build-Date>${build.date}</Build-Date>
                        </manifestEntries>
                    </archive>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>./target/dist</directory>
                        </resource>
                    </webResources>
                </configuration>
            </execution>
        </executions>
    </plugin>

However, despite this configuration, it still fails as follows:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

I don't actually have a web XML, so I need it to assemble a war without it

I tried to add a fake < webxml > none < / webxml > into the configuration, but nothing changed

I'm missing what

Solution

The execution ID in POM is prepare for war For projects with a wrapper type of war, Maven runs its own default war plug-in The default execution ID is default war Due to the current configuration of POM, the war target is twice

If you see an error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project com.specktro.orchid.operations.portal.frontend: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

You may see that the execution ID fails in parentheses (default war) If you change the execution ID to default war, your problem will disappear and you will not execute the war goal twice

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>