idea中使用tomcat 方式启动spring boot项目
Spring boot 的main 入口启动方式相信都会用,直接运行main直接就启动了,但是往往这种方式并不是最佳的启动方式,比如运维的层面更希望调整tomcat的调优参数,而只使用嵌入启动方式很难做到这些。所以使用tomcat方式启动spring boot就比较重要。
1、去tomcat 官网下载 tomcat 8 tar.gz 文件,然后解压.
https://tomcat.apache.org/download-80.cgi
2、idea中,配置启动



3、gradle or maven 配置
<packaging>war</packaging>
or
apply plugin: "war"
4、增加tomcat启动调用spring boot初始化入口:
public class ServletInitializer extends SpringBootServletInitializer {
private Logger logger = LoggerFactory.getLogger(ServletInitializer.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
logger.info("starting spring boot initializer ......");
return application.sources(MainApplication.class);
}
}
or
package com.example.demo; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication
public class Application extends SpringBootServletInitializer { @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
} public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
5、start runing
搞定!
idea中使用tomcat 方式启动spring boot项目的更多相关文章
- IntelliJ IDEA启动spring boot项目出现Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[]]
IntelliJ IDEA启动spring boot项目出现Failed to start component [StandardEngine[Tomcat].StandardHost[localho ...
- 右击main 方法运行正常,启动tomcat 后,spring boot 项目 出现参数字符串是乱码的情况
PrintWriter out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8")) ...
- 启动spring boot项目
启动spring boot项目 pom.xml如下: <?xml version="1.0" encoding="UTF-8"?> <proj ...
- 启动spring boot项目时报错:java.lang.ClassNotFoundException: javax.servlet.Filter
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- 使用Spring boot整合Hive,在启动Spring boot项目时,报错
使用Spring boot整合Hive,在启动Spring boot项目时,报出异常: java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.S ...
- 错误: 找不到或无法加载主类(IDEA中启动spring boot项目)
版权声明:本文为博主原创文章,如果转载请给出原文链接:http://www.jufanshare.com/content/142.html 提示:需要对IDEA编辑工具使用熟悉 出现一个问题,就是sp ...
- Windows系统配置.bat启动spring boot项目jar
背景:项目用spring boot构建,maven管理,本地测试好之后打成jar包,在dos窗口可以通过:java -jar demo.jar来启动demo项目,一旦关闭该dos窗口demo项目也被停 ...
- 启动Spring boot项目报错:java.lang.IllegalArgumentException: LoggerFactory is not a Logback
java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on t ...
- tomcat 启动Spring boot 项目
SpringBoot 项目如何在tomcat容器中运行 1.相关连接: https://blog.csdn.net/u010598360/article/details/78789197/ 2.修改打 ...
随机推荐
- java递归方法求数组最大元素
一直对递归写法不是很熟悉,特写一个增进理解 /** * Created by Administrator on 2017-11-01. */ public class recursion { priv ...
- 用vim去掉utf-8 BOM
'去掉utf-8 BOM :set nobomb '保留utf-8 BOM :set bomb
- 【转】一口气读懂NB-IoT
在过去的一年多,NB-IoT真的可以说是大红大紫.在通信圈里,除了说5G,就是说物联网.如果说物联网,八成就是在说NB-IoT. 在目前5G还没来的情况下,NB-IoT基本上是独领风骚.风光无限. 各 ...
- Redis事务介绍
概述 相信学过Mysql等其他数据库的同学对事务这个词都不陌生,事务表示的是一组动作,这组动作要么全部执行,要么全部不执行.为什么会有这样的需求呢?看看下面的场景: 微博是一个弱关系型社交网络,用户之 ...
- oracle 11g 压缩数据文件
通过以下语句直接分析出每个数据库文件可压缩量 select a.file#, a.name, a.bytes CurrentMB, ceil(HWM ResizeTo, (a.bytes Releas ...
- bzoj 1825: [JSOI2010]蔬菜庆典
1825: [JSOI2010]蔬菜庆典 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 112 Solved: 45[Submit][Status][ ...
- bzoj4784【zjoi2017】仙人掌
题目描述 如果一个无自环无重边无向连通图的任意一条边最多属于一个简单环,我们就称之为仙人掌.所谓简单环即不经过 重复的结点的环. 现在九条可怜手上有一张无自环无重边的无向连通图,但是她觉得这张图中的边 ...
- OpenCV-跟我学一起学数字图像处理之中值滤波
中值滤波(median filter)在数字图像处理中属于空域平滑滤波的内容(spatial filtering).对消除椒盐噪声具有很好的效果. 数学原理 为了讲述的便捷,我们以灰度图为例.RGB三 ...
- HDU 6040 stl
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others ...
- SQL2005函数大全
表达式:是常量.变量.列或函数等与运算符的任意组合.以下参数中表达式类型是指表达式经运算后返回的值的类型 字符串函数 函数名称 参数 示例 说明 ascii (字符串表达式) select ascii ...