[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on pr

以前是在eclipse中将maven项目打包,今天在idea打包maven项目中遇到错误信息

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

上网找了之后发现是因为maven默认寻找的web项目结构文件名webapps,而idea上自动生成的为web文件名,所以这里需要进行修改,而且默认的打包方式为jar包,这里需要在pom.xml文件中加入以下:

<packaging>warpackaging>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-war-pluginartifactId>
                <version>3.0.0version>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>webdirectory>
                        resource>
                    webResources>
                configuration>
            plugin>
        plugins>
    build>

其中web为你web文件存放的文件名,比如我这里的

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on pr_第1张图片


然后点击右侧的maven projects 中的package即可打包在项目文件中的target文件夹下。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on pr_第2张图片

你可能感兴趣的:(web)