【发布时间】:2020-02-22 14:25:26
【问题描述】:
我无法使用 https 运行 Spring Boot 应用程序。我知道 Spring boot 使用的是嵌入式 tomcat 服务器
下面是堆栈跟踪
org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1008) ~[tomcat-embed-core-9.0.26.jar!/:9.0.26]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.26.jar!/:9.0.26]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) [tomcat-embed-core-9.0.26.jar!/:9.0.26]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:263) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:195) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:297) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) [spring-context-5.1.10.RELEASE.jar!/:5.1.10.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.9.RELEASE.jar!/:2.1.9.RELEASE]
at com.leapanalysis.apis.application.LAApplication.main(LAApplication.java:33) [classes!/:0-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_222]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_222]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_222]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_222]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [apis.jar:0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [apis.jar:0-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [apis.jar:0-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [apis.jar:0-SNAPSHOT]
but has failed to stop it. This is very likely to create a memory leak. Stack trace of
APPLICATION FAILED TO START
Description
The Tomcat connector configured to listen on port 8181 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 8181, or configure this application to listen on another port.
下面显示的是我的 Yaml 文件
server:
port: 8181
ssl:
enabled: true
key-alias: tomcat
key-password: tomcat
key-store-password: tomcat
key-store: classpath:keystore.p12
key-store-type: PKCS12
我已经尝试了 stackoverflow 中的几乎所有答案
我尝试的一些答案如下:
只有在运行 jar 文件时才会发生这种情况,我可以轻松地从 IDE 运行 spring boot 应用程序(我使用 Intellij)
- 将端口从 8181 更改为 8443(还有许多其他端口)
在运行 jar 文件时明确指定服务器端口 (java -jar --server.port=8661)
创建并尝试了 JKS 和 PKCS12 文件(没有运气)
我使用 netsat -nltp | 检查了端口中是否有任何其他应用程序正在运行。 grep : (这里没有列出任何应用程序) - 在 root 中也检查了相同的命令,没有列出任何内容
这只会在指定 ssl 文件时发生,如果 yaml 文件中没有 ssl 详细信息,则应用程序很容易启动。
感谢任何帮助。提前致谢
【问题讨论】:
标签: java spring-boot tomcat intellij-idea server