springBoot打war包

首先在pom.xml下弃置tomcat


            org.springframework.boot
            spring-boot-starter-tomcat
            provided
        

添加war标志

 war

引入后pom.xml展现

.

    4.0.0

    com.moon
    mcxdc
    war
    1.0-SNAPSHOT

    
        org.springframework.boot
        spring-boot-starter-parent
        2.1.3.RELEASE
         
    
    Demo project for Spring Boot

    
        1.8
    
    
    
        
            org.springframework.boot
            spring-boot-starter-data-solr
        
        
        
            org.springframework.boot
            spring-boot-configuration-processor
            true
        
        
            org.springframework.boot
            spring-boot-starter-web
        
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
            org.springframework.boot
            spring-boot-starter-tomcat
            provided 
        
    
    
    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    

application.yml

server:
  port: 8099

在主启动类中加配置

package com.moon;

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

@org.springframework.boot.autoconfigure.SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class SpringBootApplication   extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootApplication.class);
    }


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

点击右侧的Maven
springBoot打war包_第1张图片
注意:一定注意yam里配置的端口号不要和tomcat的冲突

你可能感兴趣的:(SpringBoot)