web.xml is missing and is se

用maven新建springMVC的demo项目时,为了做一个不需要配置文件的demo,自定义了一个资源初始化的类,并删除了web.xml,但这时maven报错:web.xml is missing and <failOnMissingWebXml> is set to true

解决办法是:在pom.xml中failOnMissingWebXml设为false,如下:

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>rest.SpringMVC2</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
 
        <finalName>rest.SpringMVC2</finalName>
        <!--rest.SpringMVC2是我自己的项目名字 -->
    </build>

这时问题即解决。

另:如果你又想配置web.xml。这时的做法是:右击项目--> Java EE Tools -->Generate Deployment Descriptor Stub,然后web.xml则自己出现在项目里的WEB-INF下。

你可能感兴趣的:(web.xml is missing and is se)