Problem Solving 20: SpringBoot2.0 fight the war package available

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. If you need authorization, please contact [email protected] https://blog.csdn.net/leeue/article/details/90258517

SpringBoot fight the war package steps:

1. Modify the package pom file format to be modified war

  <packaging>war</packaging>

2. Add the required pom.xml build file

 <!--没有主清单属性-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <mainClass>com.leeue.App</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>

            </plugin>


            <!--        war包需要-->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <!--如果想在没有web.xml文件的情况下构建WAR,请设置为false。-->
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>


        </plugins>


    </build>

3, the most important. The App.java which modify and rewrite configure method inherited SpringBootServletInitializer

public class App extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(App.class);
    }
}

Guess you like

Origin blog.csdn.net/leeue/article/details/90258517