Spring Config服务器:找不到信任库资源位置不能为空

时间:2018-07-11 12:22:04

标签: spring spring-cloud-config

我遇到此异常:

java.lang.IllegalArgumentException: Resource location must not be null
    at org.springframework.util.Assert.notNull (Assert.java:193)
    at org.springframework.util.ResourceUtils.getURL (ResourceUtils.java:130)
    at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSslKeyStore (SslConnectorCustomizer.java:133)
    at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSsl (SslConnectorCustomizer.java:92)
    at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.customize (SslConnectorCustomizer.java:58)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeSsl (TomcatServletWebServerFactory.java:317)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeConnector (TomcatServletWebServerFactory.java:300)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer (TomcatServletWebServerFactory.java:166)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer (ServletWebServerApplicationContext.java:179)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh (ServletWebServerApplicationContext.java:152)
    at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicationContext.java:544)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh (ServletWebServerApplicationContext.java:140)
    at org.springframework.boot.SpringApplication.refresh (SpringApplication.java:759)
    at org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:395)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:327)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1255)
    at org.springframework.boot.SpringApplication.run (SpringApplication.java:1243)
    at com.tsystems.iberia.tdev.wsecsccs.WsecSccsApplication.main (WsecSccsApplication.java:12)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    ....

如您所见,它告诉我:资源位置不能为空

与spring配置有关的问题是:

server.ssl.trust-store: file:keystore.jks
server.ssl.trust-store-password: secret

很显然,keystore.jks存在并且包含证书。这就是我建立ketstore的方式:

$ keytool -importcert -trustcacerts -file ra-sec.pem -alias vault.ra-sec.svc -keystore keystore.jks

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我不太了解何时发生此错误。也许您只需要在配置文件中指定keystore.jks文件即可。 在application.yml文件中添加配置。 例如

encrypt:
  keyStore:
    location: file://Users/folder/mykey.jks
    password: password
    alias: mytestkey
    secret: secret