您的位置:首页 > 产品设计 > UI/UE

Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in

2014-05-07 15:00 381 查看
今天一个web项目启动报错:错误信息如下

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

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging.

[ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles:

[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
页面也无法正常显示,报404错误



原因说明:

maven的web项目默认的webroot是在src\main\webapps。如果在此目录下找不到web.xml就抛出以上的异常

解决方式:

在web工程pom.xml中增加plugin配置:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webXml>src\main\webapps\WEB-INF\web.xml</webXml>
</configuration>
</plugin>


运行步骤:

1.maven clean

2.maven package

以下是构建成功日志,以供大家参考。

[WARNING] Command line option -npr is deprecated and will be removed in future Maven versions.

[INFO] Scanning for projects...

[INFO]

[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building mafka-cms 1.0.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

Downloading: http://nexus:8081/nexus/content/groups/public-snapshots/com/xxx/mtrace/mtrace/1.0.5-SNAPSHOT/maven-metadata.xml
Downloaded: http://nexus:8081/nexus/content/groups/public-snapshots/com/xxx/mtrace/mtrace/1.0.5-SNAPSHOT/maven-metadata.xml (361 B at 1.8 KB/sec)

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mafka-cms ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory /Users/lizhitao/mt_wp/mafka/mafka-cms/src/main/resources

[INFO]

[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ mafka-cms ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mafka-cms ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 1 resource

[INFO]

[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ mafka-cms ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ mafka-cms ---

[INFO] Tests are skipped.

[INFO]

[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ mafka-cms ---

[INFO] Packaging webapp

[INFO] Assembling webapp [mafka-cms] in [/Users/lizhitao/mt_wp/mafka/mafka-cms/target/mafka-cms]

[INFO] Processing war project

[INFO] Webapp assembled in [416 msecs]

[INFO] Building war: /Users/lizhitao/mt_wp/mafka/mafka-cms/target/mafka-cms.war

[INFO] WEB-INF/web.xml already added, skipping

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 3.871 s

[INFO] Finished at: 2014-05-07T15:36:33+08:00

[INFO] Final Memory: 12M/228M

[INFO] ------------------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐