zoukankan      html  css  js  c++  java
  • Spring boot 用idea打包成 war

    Spring boot 用idea打包成 war

    在pom中添加(添加之后程序无法启动)

      <!--打包需要的-->
        <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <scope>provided</scope>
            </dependency>
            <!--End打包需要的-->
    
    

    把之前的main换成

    之前的mian

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.context.web.SpringBootServletInitializer;
    import org.springframework.web.WebApplicationInitializer;
    
    @SpringBootApplication
    public class SpringBootSampleApplication/* extends SpringBootServletInitializer*/ {
    
    	/*@Override
    	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    		return application.sources(SpringBootSampleApplication.class);
    	}*/
    
    	public static void main(String[] args) {
    		   SpringApplication.run(SpringBootSampleApplication.class, args);
    	}
    	
    }
    
    

    现在的

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.builder.SpringApplicationBuilder;
    import org.springframework.boot.context.web.SpringBootServletInitializer;
    import org.springframework.web.WebApplicationInitializer;
    
    @SpringBootApplication
    public class SpringBootSampleApplication extends SpringBootServletInitializer {
    
    	@Override
    	protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    		return application.sources(SpringBootSampleApplication.class);
    	}
    
    	public static void main(String[] args) {
    		   SpringApplication.run(SpringBootSampleApplication.class, args);
    	}
    	
    }
    
    

    然后BUild -> BUildArtifacts... -> 选中当前项目选中BUild 即可

  • 相关阅读:
    147
    UVA12230 过河 Crossing Rivers
    重聚
    网络流24题 P2762 太空飞行计划问题
    网络流24题 P2756 飞行员配对方案问题
    网络流24题
    洛谷 P3369 【模板】普通平衡树
    LOJ #6280. 数列分块入门 4
    LOJ #6279. 数列分块入门 3
    LOJ #6278. 数列分块入门 2
  • 原文地址:https://www.cnblogs.com/AngeLeyes/p/7818129.html
Copyright © 2011-2022 走看看