java - Spring Boot Config Server 添加 Vault,无法取回 propertySources
问题描述
我对 Sprint Boot 很陌生,当我使用本机获取本地配置时,它运行良好,我开始使用 Vault 存储配置,不知道为什么无法取回 Vault Secret。
我正在使用最新的 java 版本 16。 org.springframework.boot: 2.5.4
如果有人有经验,请帮我弄清楚,我已经卡了好几天了。
应用程序.yml
spring:
application:
name: config-server
profiles:
active: native, vault
cloud:
config:
server:
- type: native
search-locations: classpath:/config
- type: vault
port: 8200
host: 127.0.0.1
kvVersion: 2
server:
port: 8071
encrypt:
key: secretkey
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.optimagrowth</groupId>
<artifactId>configserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Configuration Server</name>
<description>Configuration Server</description>
<properties>
<java.version>16</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
<docker.image.prefix>first-spring-project</docker.image.prefix>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<!--
Spring Cloud BOM (Bill of Materials) definition
All the subprojects that make up Spring Cloud are packaged under one Maven BOM and released as a whole.
-->
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- This plugin is used to create a docker image and publish the image to docker hub-->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<configuration>
<repository>${docker.image.prefix}/${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
<executions>
<execution>
<id>default</id>
<phase>install</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
邮递员 GET 方法
解决方案
推荐阅读
- arrays - 如何提高脚本的执行速度
- pandas - 使用 plotly 按列名着色
- javascript - React 组件更新较晚
- android - 如何请求 GPS 定位许可以“始终允许”?
- amazon-s3 - Quicksight Athena - [Simba][AthenaJDBC](100071) AWS Athena 客户端引发错误
- c - 数组中的随机字符不重复
- javascript - Swiper 更改延迟加载的图像
- python-3.x - 如何使用 AWS python3 Lambda 将数据发送到 S3 存储桶?
- mysql - 如何旋转此源表
- python - Pandas:ValueError:工作表索引 0 无效,找到 0 个工作表