我得到以下错误:
装配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
是什么导致了这种情况?
当前回答
根据文档,它说:如果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>
希望它能让你更清楚
其他回答
我的webXml标签的值需要看起来像这样才能工作:
<webXml>${project.basedir}\src\main\webapp\WEB-INF\web.xml</webXml>
这对我也有用。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WebContent\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
我在尝试将Spring Boot项目打包为WAR文件并在独立的Tomcat实例中部署该WAR文件时遇到了这条消息。
我使用Spring initializr来生成初始的pom.xml和相关工件。 问题是在pom.xml (Spring版本2.6.+)中,该依赖项已经就位。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
我不得不把它换成这个:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
并且还添加了范围为"provided"的依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
当然,也改变了包装
<packaging>war</packaging>
这对我来说也是完美的。
<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>
你的文件夹结构改变了,所以文件不再在/src/main/webapp/WEB-INF/web.xml ?
为了解决这个问题,我给我的web文件夹命名为webapp,并把它放在src/main中。Maven默认在/src/main/webapp/WEB-INF/web.xml中查找web.xml。如果这样做,则不需要显式地告诉maven web.xml的位置。如果你改变了你的文件夹结构,你的构建最近停止工作,这可能是原因。
注意:这是一个旧的帖子,但是发布的解决方案并没有指出为什么一个正在工作的构建会突然停止工作。