springboot不使用内置tomcat启动,用jetty或undertow
Spring Boot启动程序通常使用Tomcat作为默认的嵌入式服务器。如果需要更改 - 您可以排除Tomcat依赖项并改为包含Jetty或Undertow:
jetty配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
JettyEmbeddedServletContainerFactory jettyContainer =
new JettyEmbeddedServletContainerFactory(); jettyContainer.setPort(9000);
jettyContainer.setContextPath("/springbootapp");
return jettyContainer;
}
undertow配置:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
@Bean
public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
UndertowEmbeddedServletContainerFactory factory =
new UndertowEmbeddedServletContainerFactory(); factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
@Override
public void customize(io.undertow.Undertow.Builder builder) {
builder.addHttpListener(8080, "0.0.0.0");
}
}); return factory;
}
9.在引导应用程序中配置Jetty或Undertow
Spring Boot启动程序通常使用Tomcat作为默认的嵌入式服务器。如果需要更改 - 您可以排除Tomcat依赖项并改为包含Jetty或Undertow:
配置Jetty
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId></dependency> |
|
1
2
3
4
5
6
7
8
9
|
@Beanpublic JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() { JettyEmbeddedServletContainerFactory jettyContainer = new JettyEmbeddedServletContainerFactory(); jettyContainer.setPort(9000); jettyContainer.setContextPath("/springbootapp"); return jettyContainer;} |
配置Undertow
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions></dependency><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-undertow</artifactId></dependency> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
@Beanpublic UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() { UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory(); factory.addBuilderCustomizers(new UndertowBuilderCustomizer() { @Override public void customize(io.undertow.Undertow.Builder builder) { builder.addHttpListener(8080, "0.0.0.0"); } }); return factory;} |
springboot不使用内置tomcat启动,用jetty或undertow的更多相关文章
- springboot学习笔记:6.内置tomcat启动和外部tomcat部署总结
springboot的web项目的启动主要分为: 一.使用内置tomcat启动 启动方式: 1.IDEA中main函数启动 2.mvn springboot-run 命令 3.java -jar XX ...
- Spring Boot 添加jersey-mvc-freemarker依赖后内置tomcat启动不了解决方案
我在我的Spring Boot 项目的pom.xml中添加了jersey-mvc-freemarker依赖后,内置tomcat启动不了. 报错信息如下: org.springframework.con ...
- Spring Boot:内置tomcat启动和外部tomcat部署总结
springboot的web项目的启动主要分为: 一.使用内置tomcat启动 启动方式: 1.IDEA中main函数启动 2.mvn springboot-run 命令 3.java -jar XX ...
- SpringBoot内置tomcat启动原理
前言 不得不说SpringBoot的开发者是在为大众程序猿谋福利,把大家都惯成了懒汉,xml不配置了,连tomcat也懒的配置了,典型的一键启动系统,那么tomcat在springb ...
- springboot之修改内置tomcat配置项
1.spring boot默认端口号是8080,如果要修改端口的话,只需要修改application.properties文件,在其中加入 例如: server.port=8081 2.在正常的项目中 ...
- eclipse内置tomcat启动方法
tomcat:run -Dmaven.tomcat.port=
- springboot内置tomcat验证授权回调页面域名
springboot内置tomcat验证公众号授权回调页面域名 解决方法: 网上下载一个tomcat,在server.xml文件中修改端口为springboot内置tomcat的端口号,复制验证文件到 ...
- SpringBoot源码篇:Spring5内置tomcat实现code-based的web.xml实现
一.简介 上篇文章讲了SpingBoot诞生的历史背景和技术演进背景,并通过源码说明了SpringBoot是如何实现零配置的包括如何省去web.xml配置的原理.本文接上一篇文章,通过demo演示Sp ...
- springboot禁用内置Tomcat的不安全请求方法
起因:安全组针对接口测试提出的要求,需要关闭不安全的请求方法,例如put.delete等方法,防止服务端资源被恶意篡改. 用过springMvc都知道可以使用@PostMapping.@GetMapp ...
随机推荐
- Tips——Flatlist的onEndReached多次触发问题解决
一.问题 RN项目里使用Flatlist组件,上拉刷新item过多时,出现跳屏.闪屏.空白屏等问题. 二.原因 先在render函数里log了一下,发现没有re-render,判断不是网络请求或页面内 ...
- JavaScript document和window属性及方法详解
[document对象] 该对象是window和frames对象的一个属性,是显示于窗口或框架内的一个文档. 属性 alinkColor 活动链接的颜色(ALINK) anchor 一个HTMI锚点 ...
- 关于CSRF跨域请求伪造的解决办法
中秋节时候我们的应用在短信验证码这块被恶意刷单,比如被用来做垃圾短信之类的,如果大规模被刷也能造成不小的损失.这还只是短信验证码,如果重要的API遭到CSRF的攻击,损失不可估量.所以紧急加班解决了C ...
- 关于HSTS的总结
访问http网站,和服务器交互的步骤浏览器向服务器发起一次HTTP请求服务器返回一个重定向地址浏览器在发送一次HTTPS请求,得到最终内容 上面浏览器发送http请求后容易被拦截,使用HSTS后可以避 ...
- Ubuntu下卸载QT5.7.1再重装
/**** 卸载QT5.7.1 *****/ .首先找到QT安装文件的位置,例如我的在/home/ttwang/software/qt5.7.1 .终端输入命令进入该目录,输入命令: ./Mainte ...
- iPhone中调用WCF服务
本文介绍的是跨平台iPhone中调用WCF服务,WCF是由微软发展的一组数据通信的应用程序开发接口,它是.NET框架的一部分,由 .NET Framework 3.0+开始引入 iPhone中调用WC ...
- Eclipse 配置 maven 的两个 settings 文件
eclipse配置的settings文件名完全可以自定义,而本机maven只认识settings.xml文件. eclipse里配置maven有一个叫全局的,有一个叫用户的.这两个文件可以和本机mav ...
- 带你从零学ReactNative开发跨平台App开发(四)
ReactNative跨平台开发系列教程: 带你从零学ReactNative开发跨平台App开发(一) 带你从零学ReactNative开发跨平台App开发(二) 带你从零学ReactNative开发 ...
- Week3——书上的分析
1.long before=System.currentTimeMills(); long after=System.currentTimeMills(); 该l两句是分别记录了开始过滤和结 ...
- 32位Windows7 利用多余的不能识别的电脑内存 RAMDISK5.5教程
32位Windows7 利用多余的不能识别的电脑内存 RAMDISK5.5教程 环境:Windows7 32位 Ultimate 内存8GB 只能识别2.95GB内存 ramdisk5.5只适用于Wi ...