構建WAR軟件包時出現Maven錯誤(缺少web.xml。
我 建議使用Maven的標準布局:
將Java源代碼放入src/main/java(并刪除sourceDirectory元素)將Web應用程序源放入 src/main/webapp刪除下的classes和lib目錄WEB-INF當然,您可以自定義布局,但這是IMO更多的麻煩和無用的工作,而不是收益。只需遵循約定。
解決方法執行時mvn install,出現以下錯誤:
組裝WAR時出錯:需要webxml屬性(如果以更新模式執行,則必須預先存在WEB-INF / web.xml)
我的Web應用程序結構樹如下所示:
my-app|-- pom.xml|-- src |-- ... |-- WebContent|-- ...|-- META-INF|-- WEB-INF |-- classes|-- ... |-- lib |-- **web.xml**
我的POM文件如下所示:
<project> <modelVersion>4.0.0</modelVersion> <groupId>masters.traffic</groupId> <artifactId>traffic_web</artifactId> <packaging>war</packaging> <name>traffic_web</name> <version>0.1.0</version> <build><sourceDirectory>src</sourceDirectory><plugins> <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin></plugins> </build> ...</project>
如何正確解決該問題?
問候
相關文章:
