10

ここに課題があります: このビルドが失敗するのはなぜですか?

不在の web.xml ファイルで失敗しないように Maven の maven-war-plugin を構成しました。

    <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>ましたが、何も変わりませんでした...

私は何が欠けていますか?

4

3 に答える 3

11

これはうまくいくはずです:

<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>このセクションは、実行ではなくプラグイン構成に移動されていることに注意してください。

于 2014-06-18T17:39:21.767 に答える
6

POM の実行 ID は ですprepare-war。Maven は、パッキング タイプ のプロジェクトに対して、war プラグインの独自のデフォルト実行を実行しますwar。デフォルトの実行には ID がありますdefault-war。POM は現在構成されているため、war目標は 2 回実行されます。

エラーメッセージを見ると:

[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、問題はなくなります。また、war ゴールを 2 回実行する必要もなくなります。

于 2014-06-18T19:09:56.443 に答える