关于springboot配置https以及端口占用问题 您所在的位置:网站首页 Springboot热部署端口被占用 关于springboot配置https以及端口占用问题

关于springboot配置https以及端口占用问题

2024-06-19 06:50| 来源: 网络整理| 查看: 265

有时候我们希望在自己本地的springboot上面配置https用作一些临时用途,本篇博客将教大家如何最简单的方式在几分钟内配置好https并使用:

一:使用jdk自带的工具生成自签名证书

打开CMD,复制粘贴:

keytool -genkey -alias tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore D:/keystore.p12 -validity 3650

最后按Y执行完成之后会在你的D盘下生成一个keystore.p12文件

二:修改springboot配置文件

将你的keystore.p12文件复制到项目的resource目录下,然后修改springboot配置文件

我用的是yml形式:

server: port: 8080 ssl: key-store: classpath:keystore.p12 key-store-password: 123456 key-store-type: PKCS12 key-alias: tomcat 三:启动,访问

如图,虽然浏览器提示不安全,但这已经成功了。

在这里插入图片描述

四:端口占用解决方案

但是有时候启动会报如下错误:

*************************** Description: The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured. Action: Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.

乍一看好像是端口被占用的错误,实则不然,其实是你的配置有问题

不信的话你把ssl相关的配置删了再看看能不能成功启动

解决方案的话就是检查一下你的配置是不是和我贴的一致



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有