我得到以下错误:
装配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
是什么导致了这种情况?
当前回答
我也遇到过同样的问题,我是这样解决的:
然后在src/main/webbapp下新建一个名为WEB-INF的文件夹
右键单击您的项目-> Java EE工具->生成部署描述符存根
这将生成web.xml
我希望这有助于解决你的问题:D
其他回答
关于包装,有两件事需要注意。
打包到war文件需要在Catalin Ciolocoiu所描述的适当文件夹中定义web.xml文件。 但是将包类型更改为jar不需要这种结构,并且应该立即工作。
根据文档,它说:如果web.xml文件丢失,是否构建失败。如果你想在没有web.xml文件的情况下构建WAR,则设置为false。如果您正在构建一个没有web.xml文件的覆盖,这可能是有用的。 缺省值:true。 用户属性为:failOnMissingWebXml。
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<extensions>false</extensions>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
希望它能让你更清楚
如果你改变默认的项目路径,你必须指定web.xml文件的位置,例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<webXml>src\main\web\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
确保在Project文件夹中正确放置了pom.xml。而不是在目标文件夹或其他任何地方。
看起来pom.xml没有相对对齐。
如果您正在从基于xml的配置迁移到基于java的配置,并且您已经通过实现WebApplicationInitializer消除了对web.xml的需求,那么只需删除对web.xml文件的要求。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
...
</configuration>