Maven 找不到 web.xml
Maven can't find web.xml
使用命令 mvn clean install
构建我的 maven 项目时出现以下错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war
(default-war) on project MyProject:
Error assembling WAR: webxml attribute is required (or pre-existing
WEB-INF/web.xml if executing in update mode)
我在项目中确实有 web.xml。在文件夹 web/WEB-INF/web.xml
我正在使用 IntelliJ IDEA。我可以通过将以下内容添加到 pom.xml:
来避免这个问题
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
但我想知道为什么 maven 声称 web.xml 丢失,即使它不是,并且在 IntelliJ IDEA 中创建新的 Web 应用程序项目时它位于默认位置。
你的问题是你在这个路径中有 web.xml
:web/WEB-INF/web.xml
对于 Maven,web.xml
应该进入 src/main/webapp/WEB-INF
或者您应该更改 war 插件的 webXml
配置(参见此处:https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#webXml )
使用命令 mvn clean install
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war
(default-war) on project MyProject:
Error assembling WAR: webxml attribute is required (or pre-existing
WEB-INF/web.xml if executing in update mode)
我在项目中确实有 web.xml。在文件夹 web/WEB-INF/web.xml
我正在使用 IntelliJ IDEA。我可以通过将以下内容添加到 pom.xml:
来避免这个问题<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
但我想知道为什么 maven 声称 web.xml 丢失,即使它不是,并且在 IntelliJ IDEA 中创建新的 Web 应用程序项目时它位于默认位置。
你的问题是你在这个路径中有 web.xml
:web/WEB-INF/web.xml
对于 Maven,web.xml
应该进入 src/main/webapp/WEB-INF
或者您应该更改 war 插件的 webXml
配置(参见此处:https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#webXml )