Spring boot – deploy

Time:2020-5-21

Spring boot – deploy

Service publishing Tomcat

  • Modify the startup class, inherit the springbootservletinitializer and override the configure method

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    return builder.sources(Start.class);
}
  • Change jar in POM file to war

<packaging>war</packaging>
  • Modify POM to exclude Tomcat plug-in

    1. Servlet API needs to be added, otherwise compilation will fail

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
  • Package and deploy to container

mvn clean package
1. Put war in the webapp directory, and pay attention to the context
    2. Put the package directory under webapp / root

summary

This is the end of the spring boot tutorial. If you want to know something else, please leave a message and I will organize it as soon as possible.

Indexes

  1. Spring boot – meet Hello world for the first time

  2. Spring boot – servlet, filter, listener, interceptor

  3. Spring boot – static resource processing, start loading, log processing

  4. Spring boot – database configuration

  5. Spring boot – deploy

last

If you think my article is useful to you, please like it and collect it. Your support will encourage me to continue to create!