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

  • 相关阅读:
    Linux下基于PAM机制的USB Key的制作
    IP-route管理路由
    Linux下CPU主板监控工具lm_sensors
    两个网卡隔离方法
    关机后内存的数据是怎么丢失的呢?
    6.0 移动端页面布局
    CyberPlayer 使用教程
    5.10 HTML5 音频和视频
    让Ecshop网店系统用户自动登陆
    設定 Bootstrap/SASS/Bower/gulp (Windows平台)
  • 原文地址:https://www.cnblogs.com/oyx305/p/5587242.html
Copyright © 2011-2022 走看看