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 ...
随机推荐
- a标签中href="javacript:;" href="javacript:void(0);" href="#"区别
在使用<a>标签时,经常会绑定其他事件比如onclick,这时候我们会给<a>标签的href属性赋值为“#”,“javacript:;”,“javacript:void(0); ...
- HDU1026(延时迷宫:BFS+优先队列)
Ignatius and the Princess I Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- /*透明度设置的两种方式,以及hover的用法,fixed,(relative,absolute)这两个一起用*/
<!DOCTYPE html> /*透明度设置的两种方式,以及hover的用法,fixed,(relative,absolute)这两个一起用*/ <html lang=" ...
- SharePoint 无法“使用资源管理器打开”
提示错误信息: 在文件资源管理器中打开此位置时遇到问题.将此网站添加到受信任的站点列表,然后重试. 服务器情况: 安装 Internet Explorer 10 后,在 Windows 资源管理器中打 ...
- [51nod1267]4个数和为0(预处理+双指针)
题意:判断能否从序列中找出4个数的和为0. 解题关键:n^2预处理任意两个数的和,sort一下,双指针进行判定. 此解法尚存在一个问题,就是左右枚举的时候如果相同的有许多的时候该左边移动还是右边移动 ...
- 在PCL中如何实现点云压缩(2)
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=125 压缩配置文件: 压缩配置文件为PCL点云编码器定义了参数集.并针对压缩 ...
- ubuntu使用root权限登录的设置方法
Ubuntu系统默认是不允许用户以root身份登录的,在网上找到的方法如下: 1.首先设置root密码,利用现有管理员帐户登陆Ubuntu,在终端执行命令:sudo passwd root,接着输入密 ...
- Cannot uninstall 'enum34'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
更新tensorflow时遇到报错 Found existing installation: enum34 1.0.4Cannot uninstall 'enum34'. It is a distut ...
- 阶段3-团队合作\项目-网络安全传输系统\sprint0-产品规划与设计\第2课-产品功能模型设计
- Entity Framework Code-First(12):Configure One-to-Many
Configure One-to-Many Relationship: Here, we will learn how to configure One-to-Many relationship be ...