gpt4 book ai didi

java - 如果我将它配置为在缺少 web.xml 时不失败,为什么 maven-war-plugin 会因 web.xml 丢失而失败?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:11:04 25 4
gpt4 key购买 nike

这是一个挑战:为什么这个构建失败了?

我已经将 Maven 的 maven-war-plugin 配置为不会在缺少的 web.xml 文件上失败,看起来:

    <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>

但尽管有这种配置,它仍然像这样失败:

[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]

我实际上没有 web.xml,所以我需要它来组装没有它的 war 。

我尝试添加伪造的 <webXml>none</webXml>进入配置,但这并没有改变任何东西......

我错过了什么?

最佳答案

这应该有效:

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
<executions>
<execution>
<id>prepare-war</id>
<phase>prepare-package</phase>
<configuration>
<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>

请注意 <failOnMissingWebXml>false</failOnMissingWebXml>部分已移至插件配置而不是执行部分。

关于java - 如果我将它配置为在缺少 web.xml 时不失败,为什么 maven-war-plugin 会因 web.xml 丢失而失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24291299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com