springBoot使用外部Tomcat启动项目
实现思路是:
将springBoot项目自带的tomcat在部署的时候不使用。
方法一:将springBoot自带tomcat编辑成只在编译和测试时使用。
转载出处:https://www.edurt.com/group/14/thread/82
- 将pom文件中jar改成war,内置tomcat要改成provide
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency> - 项目的启动类改成如下
@SpringBootApplication
@Configuration
@EnableConfigurationProperties
public class BaseApplication extends SpringBootServletInitializer { @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BaseApplication.class);
} public static void main(String[] args) {
SpringApplication.run(BaseApplication.class, args);
} }
方法二:将springBoot内置tomcat移除,添加使用外部tomcat的依赖。
一部分转载出处:https://blog.csdn.net/ke7in1314/article/details/79150713
1.重写springbootApp初始化方法
@SpringBootApplication
public class KafkaApplication extends SpringBootServletInitializer {
//继承初始化类,并重写该方法
public static void main(String[] args) {
SpringApplication.run(KafkaApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(KafkaApplication.class);
}
}
2.修改pom.xml打包方式为war
<packaging>war</packaging>
- 1
3.增加pom.xml依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
4.此方法应该添加此项(我没测试)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除嵌入式tomcat插件 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
springBoot使用外部Tomcat启动项目的更多相关文章
- springboot使用内部tomcat启动和外部tomcat启动的区别
springboot本身提供了内部tomcat,可以使用main方法直接启动即可,此时在访问项目请求时,不需要加上项目名称.例如:http://localhost:8088/user/ 如果使用外部t ...
- spring boot整合websocket之使用自带tomcat启动项目报错记录
项目中用到websocket,就将原来写好的websocket工具类直接拿来使用,发现前端建立连接的时候报404,经查找发现是因为原来用的是配置的外部tomcat启动,这次是spring boot自带 ...
- tomcat启动项目时一直在跑,项目没起来
1. 在整合maven项目时我遇到一个问题,tomcat启动项目总是报超时,后来我把timeout调到180秒,还是启动超时.看了不是timeout时间短的问题. 2.弄了一天也没解决,后来请大神给看 ...
- tomcat启动项目被重新加载,导致资源初始化两遍
之前没有遇到过这个问题,配了三天的项目了,惊人啊!!!各种怪问题全被我赶上了.真有种骂人的冲动. tomcat启动项目时,项目资源被加载两遍. 原因:配置虚拟目录导致,项目被重新加载. <Hos ...
- SpringBoot集成Socket服务后打包(war包)启动时如何启动Socket服务(web应用外部tomcat启动)
1.首先知道SpringBoot打包为jar和war包是不一样的(只讨论SpringBoot环境下web应用打包) 1.1.jar和war包的打开方式不一样,虽然都依赖java环境,但是j ...
- SpringBoot使用IDEA设置的外部Tomcat启动
前言 使用springboot内嵌的tomcat启动是没问题,但是工程是要放到服务器上的tomcat的,所以springboot内嵌的能够启动,但不代表服务器的tomcat能启动起来,我就遇到了这个问 ...
- IntelliJ IDEA通过Tomcat启动项目过程分析
Tomcat部署项目的多种方式 Tomcat安装目录:${TOMCAT_HOME} 1.常规的webapps下直接部署到${TOMCAT_HOME}/webapps下 2.利用控制台进行部署 3.外部 ...
- springboot 使用外置tomcat启动
pom.xml 如下 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...
- Springboot中,Tomcat启动war包的流程
将一个SpringBoot项目,打成war包 <!-- 1. 修改POM依赖 --> <dependency> <groupId>org.springframewo ...
随机推荐
- "_OBJC_CLASS_$_ALAssetsLibrary", referenced from:和clang: error: linker command failed with exit code 1 (use -v to see invocation)错误
在项目中使用MWPhotoBrowser未导入ALAssetsLibrary类库时会导致编译时出现异常: "_OBJC_CLASS_$_ALAssetsLibrary", refe ...
- socket发送结构体
struct send_info {char info_from[20]; //发送者IDchar info_to[20]; //接收者IDint info_length; //发送的消息主体的长度c ...
- 办公软件-Excel:Excel百科
ylbtech-办公软件-Excel:Excel百科 Microsoft Excel是Microsoft为使用Windows和Apple Macintosh操作系统的电脑编写的一款电子表格软件.直观的 ...
- Python图片识别——人工智能篇
一.安装pytesseract和PIL PIL全称:Python Imaging Library,python图像处理库,这个库支持多种文件格式,并提供了强大的图像处理和图形处理能力. 由于PIL仅 ...
- asp页面重定向
asp页面重定向 1.当你点击某页面时(没有登录),而此页面需要登录,登录后页面需要定向到你之前操作的页面时 就用到了重定向. 2.login.aspx?redirUrl="重定向的页面地址 ...
- ansible 基础 简介及 安装
ansible 运维自动化工具. 没有客户端,底层通信依赖于系统软件,linux下基于openssh,win基于powershell
- Devexpress GridControl
1.隐藏“Drag a column header here to group by that column”如下: 选择gridview->属性 选择OptionView->ShowGr ...
- Debian安装Docker
Debian 安装 Docker CE 准备工作 系统要求 Docker CE 支持以下版本的 Debian 操作系统: Stretch 9 Jessie 8 (LTS) Wheezy 7.7 (LT ...
- 《精通Spring4.X企业应用开发实战》读后感第六章(内部工作机制、BeanDefinition、InstantiationStrategy、BeanWrapper)
- Luogu 4868 Preprefix sum
类似于树状数组维护区间的方法. 每一次询问要求$\sum_{i = 1}^{n}\sum_{j = 1}^{i}a_j$. 展开一下: $\sum_{i = 1}^{n}\sum_{j = 1}^{i ...