zoukankan      html  css  js  c++  java
  • spring boot 打war包部署,打jar包

    官方文档:http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

    一:更改程序入口类 Application.java 使其继承SpringBootServletInitializer,并重写configure方法

    @SpringBootApplication
    public class Application extends SpringBootServletInitializer {
    
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
    
        public static void main(String[] args) throws Exception {
            SpringApplication.run(Application.class, args);
        }
    
    }

    二:更改pom.xml

    <packaging>war</packaging>

    三:确保内置servlet container 不会干涉发布该war包的servlet container,方案是标记内置servlet container 的依赖为provided

    <dependencies>
        <!---->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <!---->
    </dependencies>

    最后,将打好的war包放到tomcat下即可

    打成可以运行jar包

    还原上面第一步的操作,在pom.xml中添加maven-plugin

    <build>
            <plugins>
    
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
            </plugins>
        </build>

    运行:Java -jar myapp.jar

  • 相关阅读:
    JavaScript window对象属性和方法
    bzoj1878 [SDOI2009]HH的项链
    bzoj3289 Mato的文件管理
    bzoj2038 [2009国家集训队]小Z的袜子(hose)
    bzoj2333 [SCOI2011]棘手的操作
    bzoj2809 [Apio2012]dispatching
    hdu1512 Monkey King
    免费航班
    bzoj4538 [Hnoi2016]网络
    bzoj3207 花神的嘲讽计划Ⅰ
  • 原文地址:https://www.cnblogs.com/oyx305/p/5587242.html
Copyright © 2011-2022 走看看