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项目的更多相关文章

  1. 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 ...

  2. 右击main 方法运行正常,启动tomcat 后,spring boot 项目 出现参数字符串是乱码的情况

    PrintWriter out = new PrintWriter(new OutputStreamWriter(conn.getOutputStream(), "utf-8")) ...

  3. 启动spring boot项目

    启动spring boot项目 pom.xml如下: <?xml version="1.0" encoding="UTF-8"?> <proj ...

  4. 启动spring boot项目时报错:java.lang.ClassNotFoundException: javax.servlet.Filter

    <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...

  5. 使用Spring boot整合Hive,在启动Spring boot项目时,报错

    使用Spring boot整合Hive,在启动Spring boot项目时,报出异常: java.lang.NoSuchMethodError: org.eclipse.jetty.servlet.S ...

  6. 错误: 找不到或无法加载主类(IDEA中启动spring boot项目)

    版权声明:本文为博主原创文章,如果转载请给出原文链接:http://www.jufanshare.com/content/142.html 提示:需要对IDEA编辑工具使用熟悉 出现一个问题,就是sp ...

  7. Windows系统配置.bat启动spring boot项目jar

    背景:项目用spring boot构建,maven管理,本地测试好之后打成jar包,在dos窗口可以通过:java -jar demo.jar来启动demo项目,一旦关闭该dos窗口demo项目也被停 ...

  8. 启动Spring boot项目报错:java.lang.IllegalArgumentException: LoggerFactory is not a Logback

    java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on t ...

  9. tomcat 启动Spring boot 项目

    SpringBoot 项目如何在tomcat容器中运行 1.相关连接: https://blog.csdn.net/u010598360/article/details/78789197/ 2.修改打 ...

随机推荐

  1. CodeForces - 988C(STL大法好)

    请你找出两个编号不同的数列,并从这两个数列中各恰好删除一个数,使得这两个数列的和相等. 用vector存每一个数 用map标记 即可 #include <bits/stdc++.h> us ...

  2. win7右下角的同步中心怎么去除

    “开始”-“运行”-“regedit”,在“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Syncmgr\Handlers” ...

  3. 洛谷 P1306 斐波那契公约数 解题报告

    P1306 斐波那契公约数 题意:求\(Fibonacci\)数列第\(n\)项和第\(m\)项的最大公约数的最后8位. 数据范围:\(1<=n,m<=10^9\) 一些很有趣的性质 引理 ...

  4. 20165218 《网络对抗技术》 Exp5 MSF基础应用

    Exp5 MSF基础应用 实践内容 主动攻击:ms08_067 exploit/windows/smb/ms08_067_netapi generic/shell_reverse_tcp 针对浏览器攻 ...

  5. 20165218 《网络对抗技术》Exp0 Kali安装 Week1

    Kali Linux安装 下载 在Kali官网下载Kali Linux 64 Bit版本 打开VM,选择文件->新建虚拟机,一直点击下一步,注意这里选择稍后安装操作系统 版本中找不到Kali,可 ...

  6. 【cf859E】Desk Disorder

    Portal --> cf859E Solution ​​ 我们可以将每一个人看成一条边,将位置看成点,然后一个人在新的方案中可以选择的位置就是这条边连接的两个点,然后我们就得到了一个图 ​ 注 ...

  7. 团体程序设计天梯赛 L1-010. 比较大小

    测试数据: 1 2 3 1 3 2 2 1 3 2 3 1 3 1 2 3 2 1 Code: 先确定最小,然后确定第二小 #include <stdio.h> #include < ...

  8. Kubelet资源预留

    目录 Kubelet Node Allocatable 配置参数 配置示例 Kubelet Node Allocatable Kubelet Node Allocatable用来为Kube组件和Sys ...

  9. PDF文本内容批量提取到Excel

    QQ:231469242,版权所有 sklearn实战-乳腺癌细胞数据挖掘 https://study.163.com/course/introduction.htm?courseId=1005269 ...

  10. html5 +css3 点击后水波纹扩散效果 兼容移动端

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...