加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 为什么maven-war-plugin失败的web.xml失败,如果我配置它

发布时间:2020-12-14 17:48:45 所属栏目:Java 来源:网络整理
导读:这是一个挑战:为什么这个构建失败? 我已经配置了Maven的maven-war-plugin不会在一个缺失的web.xml文件中失败,似乎: plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-war-plugin/artifactId executions execution idprepare-war/id phase
这是一个挑战:为什么这个构建失败?

我已经配置了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,所以我需要它组装没有它的战争.

我尝试添加一个假的< webXml> none< / webXml>进入配置,但是没有改变任何东西…

我失踪了什么

解决方法

POM中的执行ID是准备战争.对于包装类型为war的项目,Maven运行自己的默认的war插件.默认执行有ID default-war.由于POM目前配置,战争目标是两次.

如果您看到错误信息:

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

您可能会看到执行ID在括号(default-war)中失败.如果您将执行ID更改为default-war,您的问题将会消失,您将不会再执行两次战争目标.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读