spring-boot打成war包放入tomcat运行

2020-12-13 03:56

阅读:358

标签:ram   demo   nap   ring   compile   重写   configure   from   location   

一、application集成SpringBootServletInitializer(重写configure方法)

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class Hello2Application extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        //主要目的是构建成war包使用其他Web服务器去构建。
        return builder.sources(Hello2Application.class);
    }

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

    }

}

二、配置pom.xml

4.0.0org.springframework.boot
        spring-boot-starter-parent
        2.1.6.RELEASEcom.example
    hello2
    0.0.1-SNAPSHOThello2Demo project for Spring Bootwar1.8org.springframework.boot
            spring-boot-starter-web
            org.springframework.boot
                    spring-boot-starter-tomcat 
                org.springframework.boot
            spring-boot-starter-tomcat
            
            providedorg.springframework.boot
            spring-boot-starter-test
            test
      hello2org.springframework.boot spring-boot-maven-plugin

三、完成后进行编译打包

  编译:mvn clean compile

  打包:mvn clean package

 

spring-boot打成war包放入tomcat运行

标签:ram   demo   nap   ring   compile   重写   configure   from   location   

原文地址:https://www.cnblogs.com/zhizou/p/11095469.html


评论


亲,登录后才可以留言!