Springboot release WAR start error: Error assembling War:webxml attribute is required

Source: Internet
Author: User

Spring Boot Releases the war package process:

1, modify the Web model Pom.xml

< Packaging >War</packaging>

Springboot default is to publish the jar, so to modify the default packaging method jar for the war

2. Modify the Web Model dependency (dependency)

        <Dependency>            <groupId>Org.springframework.boot</groupId>            <Artifactid>Spring-boot-starter-web</Artifactid>            <!--Remove the embedded Tomcat plugin, or scope = provided <exclusions> <exclusion> &L T;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> -

Attention:

The start dependency Spring-boot-starter-web is added here, so it is recommended to set the scope of the start dependent spring-boot-starter-tomcat to provided, The reason is simple: we might use a Servlet API like filter in our project;

Therefore, it is not recommended to remove the start-up dependency of the embedded spring-boot-starter-tomcat in Spring-boot-starter-web, because it is necessary to add SERVET-API dependencies separately

3. Maven Compilation

Don't explain

Start times Error: Error assembling War:webxml attribute is required

Obviously: Web. XML was not found under Webapp/web-inf

With spring development, all static resources + interface view are placed under resources by default, such as:

As a result, webapp are no longer present, not to mention/web-inf and/web-inf/web.xml.

Solution:

            <!--Build War <plugin> <artifactId>maven-war-plugin</artifactId> without web. xml file <version>3.0.0</version> </plugin> -            <plugin>                <Artifactid>Maven-war-plugin</Artifactid>                <version>2.6</version>                <Configuration>                    <!--set to False if you want to build the war without the Web. xml file.  -                    <Failonmissingwebxml>False</Failonmissingwebxml>                </Configuration>            </plugin>

1, the use of maven-war-plugin3.0, solve the web. XML does not exist to build a war problem

2, continue to use maven-war-plugin2.6, add settings Failonmissingwebxml=false

Get!

================================ Gorgeous split-line ====================================

However, it is strongly not recommended to use Springboot to publish a war package for three reasons:

1, the default Springboot support static resources in the way of the jar package to publish the deployment

2, the front and back end separation, the back end use springboot development, the former paragraph does not matter, completely can not rely on springboot

3, add swagger plug-in on the server side, directly through the interface to do the test, no web interface

Reference:

Spring boot use war package to deploy to Tomcat under detailed tutorial

Springboot release WAR start error: Error assembling War:webxml attribute is required

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.