首页 文章

Eclipse中的“mvn包”失败,这个maven web应用程序运行

提问于
浏览
1

执行“mvn clean package”后出现此错误:

[错误]无法在项目webapp1上执行目标org.apache.maven.plugins:maven-war-plugin:2.1.1:w ar(default-war):组装WAR时出错:需要webxml属性(或预先如果在更新模式下执行,则现有WEB-INF / web.xml) - > [帮助1]

此maven Web应用程序通过Eclipse(运行方式/在服务器上运行)顺利运行 .

1 回答

  • 9

    默认情况下 maven-war-plugin 期望webapp文件位于 ${baseDir}/src/main/webapp 文件夹中 . 在您的情况下,这些文件可以位于另一个文件夹中(Eclipse的Dynamic Web Project使用 ${baseDir}/WebContent ) . 如果是这样,您需要将这些文件移动到默认文件夹(可能需要额外的Eclipse配置)或配置 maven-war-pluginwarSourceDirectory 选项:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
            <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
    </plugin>
    

相关问题