概述

1.Spring Boot聚合工程打包war部署Tomcat

2.Spring Boot打包Jar,通过Java -jar直接运行.

3.提供完整pom.xml测试项目 至github

4.项目目前了集成了 Spring Boot + Spring data jpa +Redis集群+dubbo+freemarker 持续更新...

解决问题

1.xxxx中没有主清单属性

2.解决没有web.xml而报错

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project provider: Error assembling WAR: webxml attribute is required(or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]

版本

1.JDK 1.8

2.Spring Boot 1.5.8

3.apache-tomcat-8.5.23

一、打包war部署tomcat

1.改写App类 继承SpringBootServletInitializer

2.重写configure方法,返回builder.sources(YouApp.class);

3.添加pom.xml ,如下图

4.修改<packaging>war</packaging>

5.package命令打包

6.可参考 github--> releases--> v0.2 中blog-main-service 它是一个可打包jar且通过java -jar运行的完整项目配置

地址:https://github.com/mmdsyl/BLOG-Microservice/releases

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class ManagerApplication extends SpringBootServletInitializer{
 
  //  for tomcat
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
       return builder.sources(ManagerApplication.class);
   }
 
    public static void main(String[] args) throws InterruptedException {
        SpringApplication application = new SpringApplication(ManagerApplication.class);
        //application.setBannerMode(Banner.Mode.OFF);
         application.run(args);
    }
 
 
}

  

   <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> <!--用于解决没有web.xml报错--> <plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>

二、打包Jar执行运行

1.标准的Application,不要继承SpringBootServletInitializer

2.修改pom,如图

3.package命令打包

4.可参考 github--> releases--> v0.2 中blog-main-web ,它是一个可打包war可部署tomcat中的完整配置

地址:https://github.com/mmdsyl/BLOG-Microservice/releases

 <!--打包成jar-->
<!--https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>


-END-

Spring Boot打包war jar 部署tomcat的更多相关文章

  1. spring boot 打包war后 部署到外部 tomcat 的具体正确操作【包括修改端口 与 去除请求路径的工程名】

    1.前言 工程做好了,总不能放在idea运行吧?不然怎么把项目放到云服务器呢?[这一篇随笔不讲解发布的云服务器的操作,在其他随笔有详细记载.] 解决的方案是把springboot 工程 打包成war文 ...

  2. 一些坑 Java 执行命令行命令 Spring Boot 打包为jar ResourceUtils.getFile 等出现的问题

    Java 执行命令行命令 这个没技术含量的东西耗费了我半个多小时 String command = ....; Process process = Runtime.getRuntime().exec( ...

  3. spring boot 打war包部署,打jar包

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

  4. Spring boot打包war包

    1.设置打包的类型(war/jar) 在pom.xml里设置 <packaging>war</packaging> 2.移除嵌入式tomcat插件 //在pom.xml里找到s ...

  5. Spring Boot 以 war 方式部署

    Spring Boot 默认自带了一个嵌入式的 Tomcat 服务器,可以以jar方式运行,更为常见的情况是需要将 Spring Boot 应用打包成一个 war 包,部署到 Tomcat.Jerry ...

  6. spring boot打war包启动Tomcat失败

    Tomcat启动失败:最后一个causy by :java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getMa ...

  7. spring boot 打包成jar 包在发布到服务器上

    http://blog.csdn.net/sai739295732/article/details/49444447

  8. spring boot 打包war

    @SpringBootApplication public class AesApplication extends SpringBootServletInitializer { public sta ...

  9. spring boot 使用war包部署

随机推荐

  1. css 兼容ie8 rgba()用法

    今天遇到了一个问题,要在一个页面中设置一个半透明的白色div.这个貌似不是难题,只需要给这个div设置如下的属性即可: background: rgba(255,255,255,.1); 但是要兼容到 ...

  2. MySQL 安装与使用(三)

    操作系统:CentOS release 5.10 (Final) MySQL版本:5.1.72-community 占位学习与编辑中……

  3. linux上搭建redis

    环境centos7及redis-4.0.2.tar.gz 第一步首先在/usr/local/mypackage下mkdir redis 通过工具上传redis安装包 解压安装包 tar -zxvf r ...

  4. 利用WCF搭建RESTful--纯代码启动

    最近学习了这几年忽略了的当前几乎所有的开发技术,有深有浅,而服务层最有兴趣的是RESTfull,看的是java的书.因为不熟悉JSP,于是找了本书细细研读了一次. dotnet的实现也相对简单,网上也 ...

  5. 2018-03-10 VCard备份恢复联系人

    主要在VCardComposer类中备份联系人的逻辑 导出流程: http://blog.csdn.net/michael_yt/article/details/78270537 导入流程: http ...

  6. 准备用有人云平台和tlink.io云平台和电脑做云转发

    初步想的是用有人做国网电表转发,用tlink.io做综合采集模块转发,耗时一天 然后用tlink.io的做二次前端开发,耗时两天 用有人做二次前端开发,耗时两天 最后可以试试用常见的OPC公网转发到这 ...

  7. EBADF, read

    nodejs读取文件出的一个错误,解决不了,自己技术还达不到,解决不了这么高深的问题. 描述:需要记录访问的人数,每个人随机到的酒.打算用json文件来存储:read count write coun ...

  8. 前端开发 - JavaScript

    本节内容 一.如何编写 二.变量 三.数据类型 四.其他 五.语句与异常 六.函数 JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScri ...

  9. QuartzNet使用

    quartz.config # You can configure your scheduler in either <quartz> configuration section # or ...

  10. Kali Linux渗透测试实战 2.1 DNS信息收集

    目录 2.1 DNS信息收集1 2.1.1 whois查询3 2.1.2 域名基本信息查询4 Dns服务器查询4 a记录查询4 mx记录查询5 2.1.3 域名枚举5 fierse 5 dnsdict ...