【跪求大神】springboot 项目打包成jar后发布到CenterOS7上配置ssl证书问题

小张帅三代 2019-07-24 01:52:39
我的springboot项目发布到网上配置https,由于springboot内置有Tomca,所以打包成jar包运行。

在配置文件中配置

server.ssl.key-store=classpath:证书名.jks
server.ssl.key-store-password=证书密码
server.ssl.keyStoreType=JKS
server.port=443
server.ssl.key-alias=alias



项目文件结构:



在服务器运行项目jar的时候总是报,找不打证书文件的错误。
求大神提供解决思路。。。。


报错信息:


. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.6.RELEASE)

2019-07-24 13:12:36.001 INFO 12772 --- [ main] thezone3.Thezone3Application : Starting Thezone3Application v0.0.1-SNAPSHOT on izwz9ec51q01rdpg02i3cdz with PID 12772 (/www/wwwroot/dsq.zhangxiaosan.top/TheZone3JAR/thezone3-0.0.1-SNAPSHOT.jar started by root in /www/wwwroot/dsq.zhangxiaosan.top/TheZone3JAR)
2019-07-24 13:12:36.004 INFO 12772 --- [ main] thezone3.Thezone3Application : No active profile set, falling back to default profiles: default
2019-07-24 13:12:38.685 WARN 12772 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Could not load key store 'classpath:thezone3.jks '
2019-07-24 13:12:38.696 INFO 12772 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-24 13:12:38.730 ERROR 12772 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Could not load key store 'classpath:thezone3.jks '
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at thezone3.Thezone3Application.main(Thezone3Application.java:18) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47) [thezone3-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:86) [thezone3-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [thezone3-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [thezone3-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.web.server.WebServerException: Could not load key store 'classpath:thezone3.jks '
at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:128) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSsl(SslConnectorCustomizer.java:88) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.customize(SslConnectorCustomizer.java:57) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeSsl(TomcatServletWebServerFactory.java:319) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeConnector(TomcatServletWebServerFactory.java:303) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:170) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:179) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:152) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
... 16 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [thezone3.jks ] cannot be resolved to URL because it does not exist
at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:137) ~[spring-core-5.1.8.RELEASE.jar!/:5.1.8.RELEASE]
at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:125) ~[spring-boot-2.1.6.RELEASE.jar!/:2.1.6.RELEASE]
... 23 common frames omitted
...全文
692 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
小懒虫999 2020-10-28
  • 打赏
  • 举报
回复
打卡,签到
小张帅三代 2019-08-27
  • 打赏
  • 举报
回复
解决了 https://blog.csdn.net/qq_38313548/article/details/99695962
maradona1984 2019-07-26
  • 打赏
  • 举报
回复
如楼上所言,很少有配证书到应用层的,配在代理服务器上简单易行
码农小胖哥 2019-07-26
  • 打赏
  • 举报
回复
使用nginx 代理 然后nginx 配置证书 保你身体健康 生活愉快
小张帅三代 2019-07-25
  • 打赏
  • 举报
回复
不行啊,clear之后也不行,读取不了证书pfx文件。properties配置文件中的server.ssl.key-store=classpath:****.pfx没办法找到。而且好像识别不了classpath: 怎么办?
散着步的码农 2019-07-24
  • 打赏
  • 举报
回复
额,我也是这么配置的,是正常可用的,clean一下 再打包看看吧

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧