008-SpringBoot WAR start publishing error: Error assembling WAR: webxml attribute is required

A, Spring Boot publish the war package process:

1, modify pom.xml web model of

<packaging>war</packaging>

SpringBoot default publishing are jar, so to modify the default way of packaging jar to war

2, modified web model dependency (dependency)

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- 移除嵌入式tomcat插件,或者scope = provided
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
            -->
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>

        <!--<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>-->

note:

Added start here rely on spring-boot-starter-web, therefore, recommended that the initial dependent Spring-boot-starter-tomcat's scope set provided, the reason is very simple: our project may be used such as Servlet Filter of api;

Therefore, not recommended for spring-boot-starter-web-dependent start to remove embedded Spring-boot-starter-tomcat, because it must rely on add servet-api alone

3, maven compiler

Error on startup: Error assembling WAR: webxml attribute is required

It is clear: under webapp / WEB-INF web.xml can not be found

Use Spring development, all of the default interface view static resources + resources are placed in the following chart:

  

 

  Therefore, webapp are gone, not to mention / WEB-INF and /WEB-INF/web.xml

  solution:

            <! - Construction WAR file case without web.xml 
            <plugin> 
                <the artifactId> Maven-WAR-plugin </ the artifactId> 
                <Version> 3.0.0 </ Version> 
            </ plugin> 
            -> 
            < plugin > 
                < the artifactId > Maven-WAR-plugin </ the artifactId > 
                < Version > 2.6 </ Version > 
                < Configuration > 
                    <-! If you want to build the WAR file without web.xml case, set to false. -> 
                    < failOnMissingWebXml > to false <
                configuration>
            </plugin>

1, using the maven-war-plugin3.0, web.xml does not exist to solve the problem of war can not be built

2, continued use maven-war-plugin2.6, adding disposed failOnMissingWebXml = false

 

Guess you like

Origin www.cnblogs.com/bjlhx/p/11491297.html
Recommended