我从SpringBoot开始,我必须做一个HelloWold,但要启用SSL。我运行了我的程序,得到了以下结果:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-17 00:01:26.780 ERROR 20620 --- [ main] o.s.boot.SpringApplication : Application run failed
谁能帮我解决这个问题?
物业:
server.port=8443
server.ssl.enabled=true
server.ssl.key-store= src/main/resources/bootsecurity.p12
server.ssl.key-password=security
server.ssl.key-store-type=PKCS12
server.ssl.key-alias=bootsecurity
主要内容:
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoController {
@RequestMapping("getData")
public String demo() {
return "Hello SSL";
}
}
完整堆栈跟踪:
2020-06-17 01:35:10.278 INFO 5524 --- [ main] c.example.demo.DemoSslSpringApplication : Starting DemoSslSpringApplication on LAPTOP-EIJJNNJC with PID 5524 (C:\Users\12345\Documents\workspace-spring-tool-suite-4-4.6.2.RELEASE\DemoSSLSpring\target\classes started by Adrian in C:\Users\12345\Documents\workspace-spring-tool-suite-4-4.6.2.RELEASE\DemoSSLSpring)
2020-06-17 01:35:10.282 INFO 5524 --- [ main] c.example.demo.DemoSslSpringApplication : No active profile set, falling back to default profiles: default
2020-06-17 01:35:11.537 INFO 5524 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8443 (https)
2020-06-17 01:35:11.552 INFO 5524 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-17 01:35:11.552 INFO 5524 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-06-17 01:35:11.732 INFO 5524 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-17 01:35:11.732 INFO 5524 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1382 ms
2020-06-17 01:35:12.013 INFO 5524 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-17 01:35:13.125 WARN 5524 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
2020-06-17 01:35:13.126 INFO 5524 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-06-17 01:35:13.131 INFO 5524 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-06-17 01:35:13.156 INFO 5524 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-17 01:35:13.178 ERROR 5524 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:895) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at com.example.demo.DemoSslSpringApplication.main(DemoSslSpringApplication.java:10) ~[classes/:na]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
... 14 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1067) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
... 18 common frames omitted
Caused by: java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:99) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:71) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:216) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1064) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
... 20 common frames omitted
Caused by: java.lang.IllegalArgumentException: Private key must be accompanied by certificate chain
at java.base/java.security.KeyStore.setKeyEntry(KeyStore.java:1163) ~[na:na]
at org.apache.tomcat.util.net.SSLUtilBase.getKeyManagers(SSLUtilBase.java:355) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.SSLUtilBase.createSSLContext(SSLUtilBase.java:246) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:97) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
... 26 common frames omitted
我试图修复它,但仍然出现同样的错误。我希望有人能帮助我,我真的想把这个拿走一段时间了。我又用不同的方式做了一次,但都是一样的,或者我犯了不同的错误。
在pom文件中,将作用域从测试更改为运行时
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
这是我在运行Spring Boot程序时遇到的错误。 我的项目结构如下: 只是模型类 和StudentRepo。java我有 学生ervice.java 和文件 当我运行时,会出现如下错误 请帮帮我。谢谢大家。
我的自动配置文件在Spring Boot应用程序中不起作用。我在下面附上我的配置应用程序文件: 引发的异常如下。我怎样才能修复它?
尝试使用Intellij与Maven一起运行Java时出现此错误: 启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行应用程序。2018-04-24 01:23:18.949错误22389---[主]o.s.boot。SpringApplication:应用程序运行失败 感谢您的帮助! 主要内容: XML: 接口类: 布局: SQL: 尝试运行应用程序
我还没有任何代码,我只想配置项目 My
每当我开始一个spring boot项目时,我总是会遇到这个错误,这个问题已经在stakeoverflow上被问了多次,我已经尝试了所有的解决方案,但没有一个对我有效。我的第一个问题是这个错误的原因是什么,以及如何修复它。 过滤器应用程序。Java语言 过滤器连接器。Java语言 过滤器服务。Java语言 FilterDao.java
启动ApplicationContext时出错。要显示条件报告,请在启用“调试”的情况下重新运行应用程序。 4.0.0组织。springframework。boot spring boot starter父代2.6.6 Kodramio northwind 0.0.1-SNAPSHOT northwind spring boot演示项目