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

<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的更多相关文章
- spring boot 打包war后 部署到外部 tomcat 的具体正确操作【包括修改端口 与 去除请求路径的工程名】
1.前言 工程做好了,总不能放在idea运行吧?不然怎么把项目放到云服务器呢?[这一篇随笔不讲解发布的云服务器的操作,在其他随笔有详细记载.] 解决的方案是把springboot 工程 打包成war文 ...
- 一些坑 Java 执行命令行命令 Spring Boot 打包为jar ResourceUtils.getFile 等出现的问题
Java 执行命令行命令 这个没技术含量的东西耗费了我半个多小时 String command = ....; Process process = Runtime.getRuntime().exec( ...
- spring boot 打war包部署,打jar包
官方文档:http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable- ...
- Spring boot打包war包
1.设置打包的类型(war/jar) 在pom.xml里设置 <packaging>war</packaging> 2.移除嵌入式tomcat插件 //在pom.xml里找到s ...
- Spring Boot 以 war 方式部署
Spring Boot 默认自带了一个嵌入式的 Tomcat 服务器,可以以jar方式运行,更为常见的情况是需要将 Spring Boot 应用打包成一个 war 包,部署到 Tomcat.Jerry ...
- spring boot打war包启动Tomcat失败
Tomcat启动失败:最后一个causy by :java.lang.NoSuchMethodError: org.apache.tomcat.util.res.StringManager.getMa ...
- spring boot 打包成jar 包在发布到服务器上
http://blog.csdn.net/sai739295732/article/details/49444447
- spring boot 打包war
@SpringBootApplication public class AesApplication extends SpringBootServletInitializer { public sta ...
- spring boot 使用war包部署
随机推荐
- navigtor对象和插件检测
每一个浏览器都内置了属于自己的一套属性和方法 浏览器中navigator对象有plugins属性对象存着插件的数组 每一项包含: name 插件名称 description 插件的描述 filenam ...
- eclipse中tomcat启动设置参数
今天新接触一个项目,使用java+flex做的单机项目,由于模块太多,打成war后就有300M左右了.所以,启动的时候,比较慢,超过了e eclipse中默认的45s,当我进行修改启动事件后,有一 ...
- git 版本库拆分和subtree用法
git 版本库拆分 原文地址: https://segmentfault.com/a/1190000002548731 程序员最爽的事情是什么?删删删!所有项目本来都很苗条的,时间长了难免有一些越搞越 ...
- create table b1 as select * from b建表锁表测试
A: create table a1 like a; insert into a1 as select * from a; B: create table b1 as select * from b; ...
- HTTP协议(一)[草稿版]
(一)HTTP客户端请求头格式
- CSS Transform Style
As CSS3 developing quickly, the transform style can be written conviently. I find that it is an inte ...
- C#-VS发布网站-准备待发布网站-摘
通过使用“发布网站”工具部署网站项目 准备网站源文件 在vs生成发布文件 配置IIS .NET Framework 4 其他版本 Visual Studio 2008 Visual Studio ...
- ( 递归 )Fractal -- POJ -- 2083
http://poj.org/problem?id=2083 Fractal Time Limit: 1000MS Memory Limit: 30000K Total Submissions: ...
- Spring AOP 中pointcut expression表达式
原文地址——http://blog.csdn.net/qq525099302/article/details/53996344 Pointcut是指那些方法需要被执行”AOP”,是由”Pointcut ...
- vc6中向vs2010迁移的几个问题(2)
1. 库文件的迁移 参考:http://www.cnblogs.com/icmzn/p/6724969.html 2. 其他项目中的可能遇到的问题: 2.1 无法打开包括文件:“fstream.h”: ...