Springboot以Jetty为容器实现http重定向到https

1 简介

之前讲解的Springboot整合https用的是tomcat作为容器,tomcat也是一个流行多年的老牌Java容器了。但针对不同的场景,还是会有不同的选择,如JettyJetty是架构相对简单、基于Handler的灵活可扩展的Servlet容器。更多详情请参考官方文档

另外建议阅读其它相关文章:

(1)Springboot整合https原来这么简单

(2)HTTPS之密钥知识与密钥工具Keytool和Keystore-Explorer

(3)Springboot以Tomcat为容器实现http重定向到https的两种方式

2 重定向实现

为了代码结构清晰一点&

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
回答: 要在Spring Boot中集成Jetty容器,你需要先排除掉默认的Tomcat容器,然后引入Jetty的starter。在pom.xml文件中,你可以找到spring-boot-starter-web这个starter,并排除掉spring-boot-starter-tomcat的依赖。同时,你需要引入spring-boot-starter-jetty的依赖。下面是一段示例代码,展示了如何在pom.xml中进行配置: ```xml <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> ``` 这样配置之后,Spring Boot就会使用Jetty作为你的应用程序的容器。注意,这只是配置的一种方式,具体的配置方式可能因项目而异。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [SpringBoot:配置Jetty容器|超级详细,建议收藏](https://blog.csdn.net/weixin_43970743/article/details/130385691)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [Spring Boot 集成 Jetty](https://blog.csdn.net/weixin_34050427/article/details/88188521)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值