Spring valut配置没有加载

时间:2017-09-22 11:52:31

标签: spring spring-cloud-config hashicorp-vault

我有一个项目设置,我有一个父pom和子项目继承。我们正在使用云配置库。它作为一个单独的项目工作正常。我能够存储保险库属性并加载与此处http://cloud.spring.io/spring-cloud-vault/

链接中给出的相同

但是,我需要在我的子项目中使用具有父级

的保险库

使用下面的pom -

儿童pom <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-vault-config</artifactId> </dependency>

父母pom

<name>FEO Microservices Parent</name>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring.boot.version>2.0.0.M3</spring.boot.version>
        <spring.cloud.version>Finchley.M1</spring.cloud.version>
        <spring.cloud.stream.version>Elmhurst.BUILD-SNAPSHOT</spring.cloud.stream.version>
        <springfox.swagger2.version>2.7.0</springfox.swagger2.version>
        <guava.version>20.0</guava.version>

`

这是堆栈跟踪:

ramework.beans.factory.BeanCreationException: Error creating bean with name 'vaultBootstrapConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$3c0bf335]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Host must not be empty
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:277) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1281) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1137) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:499) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:312) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:177) ~[spring-cloud-context-2.0.0.M1.jar:2.0.0.M1]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:99) ~[spring-cloud-context-2.0.0.M1.jar:2.0.0.M1]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:65) ~[spring-cloud-context-2.0.0.M1.jar:2.0.0.M1]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:349) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317) ~[spring-boot-2.0.0.M3.jar:2.0.0.M3]
    at com.bbb.microservices.sku.SkuMicroserviceApplication.main(SkuMicroserviceApplication.java:22) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$3c0bf335]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: Host must not be empty
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:177) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:118) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    ... 26 common frames omitted
Caused by: java.lang.IllegalArgumentException: Host must not be empty
    at org.springframework.util.Assert.hasText(Assert.java:276) ~[spring-core-5.0.0.RC3.jar:5.0.0.RC3]
    at org.springframework.vault.client.VaultEndpoint.from(VaultEndpoint.java:85) ~[spring-vault-core-2.0.0.M1.jar:na]
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration.getVaultEndpoint(VaultBootstrapConfiguration.java:115) ~[spring-cloud-vault-config-2.0.0.M1.jar:2.0.0.M1]
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration.<init>(VaultBootstrapConfiguration.java:109) ~[spring-cloud-vault-config-2.0.0.M1.jar:2.0.0.M1]
    at org.springframework.cloud.vault.config.VaultBootstrapConfiguration$$EnhancerBySpringCGLIB$$3c0bf335.<init>(<generated>) ~[spring-cloud-vault-config-2.0.0.M1.jar:2.0.0.M1]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_131]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_131]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:1.8.0_131]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:165) ~[spring-beans-5.0.0.RC3.jar:5.0.0.RC3]
    ... 28 common frames omitted

2 个答案:

答案 0 :(得分:0)

您没有指定Vault属性,但根据错误判断您缺少spring.cloud.vault.host配置。将spring.cloud.vault.host=<your_vault_host>值添加到您的属性中,这应该可以帮助您。

查看Spring Cloud Vault Quick Start Guide了解详情。

答案 1 :(得分:0)

我之前使用uri而没有http://只是localhost:8200这在春季启动pre(2.0)版本中有些工作(我在配置中给了其他参数太主机名等)。但是,当我将相同的代码移动到我的项目正在使用的Spring boot 2.0时,我遇到了问题。支持小组对此进行了更正,我在uri中使用了http://并且工作正常。