咸鱼

咸鱼是以盐腌渍后,晒干的鱼

0%

springboot打war包部署到外部Tomcat

  • 配置文件pom.xml
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    <packaging>war</packaging>
    -----------------------------------完美分割线
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
    </dependency>
    -----------------------------------完美分割线
    <build>
    <finalName>testJenkins</finalName>
    </build>
  • application.properties
    1
    2
    3
    4
    5
    # context-path 和 pom.xml的build-finalName 一致
    server.context-path=/testJenkins

    #如果有指定端口,可以去掉。
    #server.port=9990
  • 编写启动类
    1
    2
    3
    4
    5
    6
    7
    8
    9
    public class TomcatServletInitializer extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

    //Application.class就是springboot的 @SpringBootApplication 类
    return application.sources(Application.class);
    }
    }
  • 命令打包
    1
    mvn package
    参考了此文