参考来源:https://www.cnblogs.com/imfjj/p/9058443.html

https://blog.csdn.net/jackymvc/article/details/81077885

配置证书:

keytool -genkeypair -alias tomcat -keyalg RSA -keystore tomcat.key

依次填入以下内容:

mcat.key
输入密钥库口令:
再次输入新口令:
您的名字与姓氏是什么?
[Unknown]: localhost
您的组织单位名称是什么?
[Unknown]: localhost
您的组织名称是什么?
[Unknown]: xxx Co,.Ltd
您所在的城市或区域名称是什么?
[Unknown]: KunShan
您所在的省/市/自治区名称是什么?
[Unknown]: SuZhou
该单位的双字母国家/地区代码是什么?
[Unknown]: China
CN=localhost, OU=localhost, O="xxxCo,.Ltd", L=KunShan, ST=SuZhou, C=Chin
a是否正确?
[否]:y 输入 <tomcat> 的密钥口令
(如果和密钥库口令相同, 按回车):
再次输入新口令:

把生成的证书放入 resources目录

配置application.yml

debug: true
server:
port:
tomcat:
max-threads:
accept-count:
min-spare-threads:
max-connections:
ssl:
key-store: classpath:tomcat.key
key-store-type: JKS
key-alias: tomcat
#证书密码
key-store-password: xxxx

中途遇到报错:

-- ::49.752 default [main] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.web.embedded.tomcat.ConnectorStartFailedException: Connector configured to listen on port failed to start
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.checkThatConnectorsHaveStarted(TomcatWebServer.java:)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java:)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:)
at com.xxx.web.WebApplication.main(WebApplication.java:)
-- ::49.752 default [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter -

解决方法:

参考来源:Spring Boot- The Tomcat connector configured to listen on port 8080 failed to start

SpringBoot 2.x

新增一个组件类


@Component
public class CustomContainer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> { @Value("${server.port}")
int serverPort; @Override
public void customize(ConfigurableServletWebServerFactory factory) {
factory.setPort(serverPort);
}
}

 

SpringBoot 1.x解决方法:

import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.stereotype.Component; @Component
public class CustomContainer implements EmbeddedServletContainerCustomizer { @Override
public void customize(ConfigurableEmbeddedServletContainer container) { container.setPort(8085); } }

SpringBoot 2.x中为tomcat配置ssl(https)支持的更多相关文章

  1. apache Tomcat配置SSL(https)步骤

    Tomcat配置https 1      生成Server端安全证书 要实现通信加密,首先要在本地准备一份符合X.509标准的Server端安全证书.如果有条件的话,可以向权威CA申请一份经过认证的安 ...

  2. linux apache Tomcat配置SSL(https)步骤

    https简介 它是由Netscape开发并内置于其浏览器中,用于对数据进行压缩和解压操作,并返回网络上传送回的结果.HTTPS实际上应用了Netscape的安全套接字层(SSL)作为HTTP应用层的 ...

  3. windows 下nginx配置ssl https支持

    本文适合正式上线的配置,购买来的证书 私钥*.key文件需要先去掉密码 openssl rsa -in old.key -out new.key

  4. Springboot 配置 ssl 实现HTTPS 请求 & Tomcat配置SSL支持https请求

    SSL(Secure Sockets Layer 安全套接层),及其继任者传输层安全(Transport Layer Security,TLS)是为网络通信提供安全及数据完整性的一种安全协议.TLS与 ...

  5. TOMCAT配置SSL认证为HTTPS协议服务

     1 . 问题概述 很多安全性要求较高的系统,都会使用安全套接字层(SSL)进行信息交换, Sun为了解决在Internet上的实现安全信息传输的解决方案.它实现了SSL和TSL(传输层安全)协议 ...

  6. 单点登录 SSO, 自动登录 , java 加密,ssl原理, Tomcat配置SSL

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha 单点登录的英文简称为SSO(single sign on),单点登录功能使得用户只要登录 ...

  7. Nginx和Tomcat配置SSL实现https访问

    环境:CentOS 7 Nginx版本: nginx/1.18.0 1. 安装nginx 详细步骤可以参考如下官网:http://nginx.org/en/linux_packages.html#RH ...

  8. 华为云服务器为Tomcat配置SSL

    近期由于开发小程序需要在云服务器上配置https访问协议,也遇到了一点小问题,把配置过程记录一下:SSL 证书申请下来之后会有 .jks .crt .pfx .pem为后缀的文件(如何申请SSL证书这 ...

  9. Tomcat配置SSL

    Tomcat配置SSL 查询网上资料配置如下: <Connector port="8443" protocol="HTTP/1.1" maxThreads ...

随机推荐

  1. jade过滤器

    以上语法基本讲完了jade的语法,然后在jade里面并不仅仅局限于使用jade语法,同样可以使用其他的插件语言,这种机制在jade里面称为filter,在jade里面加入过滤器用冒号 markdown ...

  2. 使用phpstudy搭建的外网网站 运行很慢 解决办法

    将连接数据库的配置文件 localhost  修改为127.0.0.1 PHP5.3以上,如果是链接localhost,会检测是IPV4还是IPV6,所以会比较慢.解决办法是:链接数据的时候,不要填写 ...

  3. 大数据之路week05--day02(Maven安装,环境变量的配置及基本使用)

    今天我们就来学习一下maven,怎么说呢,maven更像是一种管理的工具,实现的原理是使用插件. 举个例子,比如说,一个公司需要做一个项目,这个项目又分成了很多的模块,每个模块又分成了许多的业务等等, ...

  4. Spring Bean装配(下)——注解

    @Repository,@Service,@Controller这三个注解是基于component定义的注解 component-scan:组件扫描 base-package:扫描这个下的所有类 &l ...

  5. input 设置 display:none后 jquery无法给input赋值

    问题出现场景:为什么要用 jquery给input赋值,为什么input带有display:none 在做字典查询的时候,查询参数有字典类型的treeSelect 下拉框,treeSelect渲染后, ...

  6. BZOJ 5496: [2019省队联测]字符串问题 (后缀数组+主席树优化建图+拓扑排序)

    题意 略 分析 考场上写了暴力建图40分溜了-(结果只得了30分) 然后只要优化建边就行了 首先给出的支配关系无法优化,就直接A向它支配的B连边. 考虑B向以B作为前缀的所有A连边,做一遍后缀数组,两 ...

  7. DisplayModeProvider完成移动开发自动视图解析

    MVC中新建视图命名:XXX.cshtml.XXX.mobile.cshtml:用手机访问会自动到xxx.mobile.cshtml 一.原理 MVC中是通过DisplayModeProvider实现 ...

  8. 彻底搞清楚setState

    setState最常见的问题是,是异步的还是同步的? setState在React.Component中的函数,是同步函数.但是我们调用的时候,不同的传参和不同的调用位置都会导致不同的结果. 从页面看 ...

  9. VUE 异步数据传递给 component props 的问题

    案例一 父组件parent.vue // asyncData为异步获取的数据,想传递给子组件使用 <template> <div> 父组件 <child :child-d ...

  10. locale与C字符编码

    ref: https://www.cnblogs.com/gatsby123/p/11150472.html Unicode 字符集 代码点 与编码表中的某个字符对应的代码值.在Unicode标准中, ...