我得到以下错误:
装配WAR: webxml属性是必需的(如果以更新模式执行,则需要预先存在的WEB-INF/web.xml)
我有web.xml在正确的地方,这是projectname\src\main\webapp\WEB-INF\web.xml
是什么导致了这种情况?
我得到以下错误:
装配WAR: webxml属性是必需的(如果以更新模式执行,则需要预先存在的WEB-INF/web.xml)
我有web.xml在正确的地方,这是projectname\src\main\webapp\WEB-INF\web.xml
是什么导致了这种情况?
当前回答
Mvn-war-plugin 2.3修复了这个问题:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
...
其他回答
这是因为您没有在web项目中包含web.xml,并试图使用maven构建war。要解决这个错误,您需要在pom.xml文件中将failOnMissingWebXml设置为false。
例如:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
详情请见博客:https://ankurjain26.blogspot.in/2017/05/error-assembling-war-webxml-attribute.html
我的webXml标签的值需要看起来像这样才能工作:
<webXml>${project.basedir}\src\main\webapp\WEB-INF\web.xml</webXml>
关于包装,有两件事需要注意。
打包到war文件需要在Catalin Ciolocoiu所描述的适当文件夹中定义web.xml文件。 但是将包类型更改为jar不需要这种结构,并且应该立即工作。
这对我来说也是完美的。
<project>
.....
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Mvn-war-plugin 2.3修复了这个问题:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
...