Maven cannot find web.xml when packaging javaweb application

the project structure is like this.

pom.xml:


maven buildweb.xml


configuration:


:


:


Project Facets,:

all report the same error.

only when you change the WebContent of the project to webapp and put it under src/main/, can you successfully package
ask for advice!

Sep.07,2021

the role of web.xml

 servletweb.xml,web.xmlspring,spring,Servletweb.xml;
 Servlet X(),web.xml,tomcat;
   

Plan 1: use web.xml to guide

1.webapp,web.xml,maven-war-plugin,warwartomcat;

Plan 2: use embedded web containers

<build>
 <plugins> <!--tomcat-->
    <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration> 
            <path>/</path> <!--  :localhost:9090, aalocalhost:9090/aa -->
            <port>9090</port>
            <uriEncoding>UTF-8</uriEncoding><!--  -->
        </configuration>
    </plugin>
 <!--war-->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.1.0</version>
     </plugin> 
  </plugins>
 </build>

to add embedded tomcat plug-ins and upgrade maven-war-plugin;
maven-war-plugin to follow the servlet specification!

Menu