首先需要去做个证书

yml配置文件中设置的是https监听端口

server:
port: 10007
tomcat:
basedir: /data/apps/temp
#配置SSL
ssl:
key-store: classpath:bdcourtyard.com.jks
key-store-password: 4a98pp121wv
keyStoreType: JKS

以下是启动类添加的代码

 /**
* it's for set http url auto change to https
*/
@Bean
public TomcatEmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");//confidential
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(httpConnector());
return tomcat;
} @Bean
public Connector httpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(9000);
connector.setSecure(true);
connector.setRedirectPort(10007);
return connector;
}

这个是同事配的,实测有效搬过来具体自己还没研究

spring boot之支持http和https并行(http不跳转)的更多相关文章

  1. Spring Boot工程支持HTTP和HTTPS,HTTP重定向HTTPS

    本文试图以通俗易通的方式介绍Https的工作原理,不纠结具体的术语,不考证严格的流程.我相信弄懂了原理之后,到了具体操作和实现的时候,方向就不会错,然后条条大路通罗马.阅读文本需要提前大致了解对称加密 ...

  2. Spring Boot系列教程十四:Spring boot同时支持HTTP和HTTPS

    自签证书 openssl生成服务端证书,不使用CA证书直接生成 -in server.csr -signkey server.key -out server.crt # 5.server证书转换成ke ...

  3. spring cloud/spring boot同时支持http和https访问

    l老规矩为大家祭出原帖:https://www.cnblogs.com/lianggp/p/8136540.html  不再转述

  4. 【杂谈】Spring Boot 默认支持的并发量

    Spring Boot应用支持的最大并发量是多少? Spring Boot 能支持的最大并发量主要看其对Tomcat的设置,可以在配置文件中对其进行更改.当在配置文件中敲出max后提示值就是它的默认值 ...

  5. Spring Boot同时开启HTTP和HTTPS服务

    由于Spring Boot中通过编码开启HTTPS服务比较复杂,所以官方推荐通过编码开启HTTP服务,而通过配置开启HTTPS服务. Spring Boot的application.yml中添加如下配 ...

  6. Spring Boot 版本支持对应JDK

    转自:http://www.cnblogs.com/oumi/p/9241424.html 一.Spring Boot 版本支持 Spring Boot Spring Framework Java M ...

  7. Spring Boot 默认支持的并发量

    Spring Boot应用支持的最大并发量是多少? Spring Boot 能支持的最大并发量主要看其对Tomcat的设置,可以在配置文件中对其进行更改.当在配置文件中敲出max后提示值就是它的默认值 ...

  8. Spring Boot 版本支持

    一.Spring Boot 版本支持 Spring Boot Spring Framework Java Maven Gradle 1.2.0之前版本   6 3.0+ 1.6+ 1.2.0 4.1. ...

  9. Spring Boot全局支持CORS(跨源请求)

    import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet. ...

随机推荐

  1. Watchtower - 自动更新 Docker 镜像与容器

    git 地址:https://github.com/containrrr/watchtower Docker images docker pull containrrr/watchtower:i386 ...

  2. springboot整合websocket后打包报错:javax.websocket.server.ServerContainer not available

    项目整合了websocket以后,打包多次都没有成功,原来是报错了,报错内容如下: Error starting ApplicationContext. To display the conditio ...

  3. Mybatis—curd

    Mybatis简介: MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为 ...

  4. vue项目中遇到的问题(包含兼容性问题)

    一.由于懒加载,使用elementUI里面的dialog的时候dialog还未被渲染成DOM元素,调用清空表单验证的方法会报错this.$refs[formName].resetFields(); 解 ...

  5. Linux系统时间同步方法

    在Windwos中,系统时间的设置很简单,界面操作,通俗易懂,而且设置后,重启,关机都没关系.系统时间会自动保存在BIOS时钟里面,启动计算机的时候,系统会自动在BIOS里面取硬件时间,以保证时间的不 ...

  6. soso官方:搜索引擎的对检索结果常用的评测方法

    http://www.wocaoseo.com/thread-188-1-1.html       很久很久以前,搜索引擎还不象今天的百花齐放,人们对它的要求较低,只要它能把互连网上相关的网站搜出来, ...

  7. 【Android】SwipeRefreshLayout的简单使用教程。下拉刷新控件炫酷效果。

    作者:程序员小冰,GitHub主页:https://github.com/QQ986945193 新浪微博:http://weibo.com/mcxiaobing 首先给大家看一下我们今天这个最终实现 ...

  8. rake

    ruby-rake https://rubygems.org/gems/rake 官方文档 https://ruby.github.io/rake/ http://docs.seattlerb.org ...

  9. Pinpoint 一款强大的APM工具

    背景 程序的监控一直是程序员最头痛的事情之一,现网程序有问题怎么办?看进程看端口 top/free/df 三件套?网络抓包?看日志?所以为了满足这些初级需求很多公司都做了主机监控,进程端口监听等功能, ...

  10. vue 图片路径问题

    图片路径问题 module.exports = { // 根据环境区分 生产服务器production比如php服务器的地址 和 开发服务器dev的地址 // npm run serve是开发环境de ...