Spring Boot打包war jar 部署tomcat

概述

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);

}

}

复制代码

1<dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-tomcat</artifactId> 4 <scope>provided</scope> 5 </dependency> 6 7 <!--用于解决没有web.xml报错--> 8 9 <plugin> 10 <artifactId>maven-war-plugin</artifactId> 11 <version>3.0.0</version> 12 </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

1 1 <!--打包成jar--> 2 2 <!--https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html--> 3 3 <plugin> 4 4 <groupId>org.springframework.boot</groupId> 5 5 <artifactId>spring-boot-maven-plugin</artifactId> 6 6 <executions> 7 7 <execution> 8 8 <goals> 9 9 <goal>repackage</goal> 1010 </goals> 1111 </execution> 1212 </executions> 1313 </plugin>

 -END-

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )