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 即可

  • 相关阅读:
    用递归实现因式分解
    linux文件 面试知识
    嵌入式软件面试小点
    带环链表的几个问题
    C++对象的内存布局以及虚函数表和虚基表
    手把手教你用 React Hooks 开发移动端网站,从入门到实践
    你闺女都能看懂的 Kubernetes 插画指南!
    使用卷积神经网络识别交通标志
    6 个前端开发必备工具,提高你的生产力
    给新手看的 Micronaut 入门教程,10 分钟写出一个Micronaut程序
  • 原文地址:https://www.cnblogs.com/AngeLeyes/p/7818129.html
Copyright © 2011-2022 走看看