如何配置Spring Boot以同时使用Vault和属性文件?

时间:2019-06-21 15:07:53

标签: java spring-boot hashicorp-vault

我已经设置了Spring Boot应用程序以从HashiCorp Vaults实例读取配置。我有一个“ bootstrap.yml”,其中包含保管箱的连接+身份验证信息。但是,我只想使用保管库获取敏感信息,而更喜欢将“ application.properties”用于其他配置。可以同时使用两者吗?

这是我在启动应用程序时遇到的错误:

java.lang.AbstractMethodError: null
    at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:68) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360) ~[na:1.8.0_181]
    at java.util.TimSort.sort(TimSort.java:220) ~[na:1.8.0_181]
    at java.util.Arrays.sort(Arrays.java:1512) ~[na:1.8.0_181]
    at java.util.ArrayList.sort(ArrayList.java:1462) ~[na:1.8.0_181]
    at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1344) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1253) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:408) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:331) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at com.example.demo.Application.main(Application.java:15) [classes/:na]

这是pom.xml的摘录:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-vault-config</artifactId>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>

0 个答案:

没有答案