【maven】web專案不需要web.xml,maven打包報錯
在maven 打包war包的時候,它會要求/WEB-INF目錄下有web.xml檔案,但是在servlet 3.0之後,對於web.xml檔案本身是可選的,當我用maven打包的時候報錯如下錯誤:
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project core-frontend: 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.
解決方式有兩個:
1 在pom.xml檔案中定義一個引數配置
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
2 另外你可以更新maven的預設的maven-war-plugin
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>