pom.xml文件报错web.xml is missing and <failOnMissingWebXml> is set to true问题

这个问题是因为项目是打包方式是war,但是没有找到web.xml文件

在/src/main/webapp/WEB-INF目录下添加web.xml文件即可以解决

web.xml文件模板如下

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">  

</web-app>

添加web.xml模板可能会报错,这是因为约束文件没有找到,ide会自动去下载,等下载完成之后就不会报错了


或者在pom文件中添加如下配置

 <build>  
    <plugins>  
        <plugin>  
            <groupId>org.apache.maven.plugins</groupId>  
            <artifactId>maven-war-plugin</artifactId>  
            <version>2.5</version>  
            <configuration>  
                <failOnMissingWebXml>false</failOnMissingWebXml>  
            </configuration>  
        </plugin>  
    </plugins>  
</build>

猜你喜欢

转载自blog.csdn.net/Let_me_tell_you/article/details/80938676