gpt4 book ai didi

java - 如何在 Spring 中将资源类型从 ServletContextResource 更改为 FileSystemResource

转载 作者:行者123 更新时间:2023-12-01 18:35:16 32 4
gpt4 key购买 nike

我在 Spring boot 中打开证书存储时遇到问题。我的应用程序是一个 war 文件,并且证书存储位于外部路径上。

我得到的错误是:嵌套异常为 java.lang.IllegalStateException:资源 'ServletContext 资源 [/"file:C:/cert/client-keystore.jks"]' 必须位于文件系统上

我将此错误理解为 Spring 尝试打开 ServletContextResource,而我猜它应该是 FileSystemResource。如何强制Spring重新分类资源?

文件在那里: enter image description here

从应用程序属性中读取的路径为:

spring.kafka.producer.ssl.key-store-location="file:C:/cert/client-keystore.jks"

文件读取为:@PropertySource(value = { "file:c:/path/application.properties"})

感谢您的帮助。

巴西、旧金山

最佳答案

将语法更改为以下后,我得到了它的工作:spring.kafka. Producer.ssl.key-store-location=C:/cert/client-keystore.jks

正在从路径中删除文件:

巴西、旧金山

关于java - 如何在 Spring 中将资源类型从 ServletContextResource 更改为 FileSystemResource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60071550/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com