我对 Spring Cloud 配置客户端应用程序有一些问题。当我在 pom.xml 中使用 spring-boot-starter-parent 作为父级(如下所示)时,我的应用程序工作正常并且能够从 Spring Cloud 配置服务器获取属性。
<?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.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>**
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2020.0.1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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>
<build>
<plugins>
<plugin> …Run Code Online (Sandbox Code Playgroud) java spring-boot spring-boot-maven-plugin spring-cloud-config spring-cloud-config-server
我正在开发Spring Boot 2.4.2.RELEASE并config-server为我的微服务项目进行开发。以下是我迄今为止开发的代码。
配置服务器应用程序
@SpringBootApplication
@EnableConfigServer
@EnableEurekaClient
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序属性
spring.application.name=config-server
server.port=9296
spring.cloud.config.server.git.uri=https://github.com/shabbirdwd53/config-server
spring.cloud.config.server.git.clone-on-start=true
Run Code Online (Sandbox Code Playgroud)
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.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>config-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>config-server</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.2</spring-cloud.version>
</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.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> …Run Code Online (Sandbox Code Playgroud) 我想在我的配置服务器中使用私有 git 存储库。这是我的application.yml:
server:
port: 100
spring:
application:
name: smth-config-server
cloud:
config:
server:
git:
uri: https://github.com/smth/smth
default-label: main
username: smth
password: smth
host-key-algorithm: ssh-rsa
ignore-local-ssh-settings: true
host-key: ssh-rsa smth== github.com
private-key: -----BEGIN RSA PRIVATE KEY-----
smth
-----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/smth/smth: not authorized
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:544)
Run Code Online (Sandbox Code Playgroud)
我应该如何修复它?
git spring spring-boot spring-cloud spring-cloud-config-server
我正在尝试运行 Spring Cloud 配置服务器,完成一本书中的示例(Manning's Spring Microservices in Action),但更新到最新版本:Java 17,spring-boot-starter-parent 2.6.1,使用 Spring Cloud 2021.0.0-RC1。
每次我尝试启动服务器时,都会收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)
我没有使用该git配置文件。我尝试了两种不同的配置文件:(native在类路径上使用配置文件)和vault(在本地运行 Hashicorp Vault 服务器)。我的最新内容/src/resources/bootstrap.yml包含以下内容:
spring:
application:
name: config-server
profiles:
active: vault
cloud:
config:
server:
vault:
port: …Run Code Online (Sandbox Code Playgroud) 我将在 openshift 中部署一个 Node js 服务,并且需要外部化一些属性,例如数据库配置和应用程序属性。
我有 Java 应用程序作为解决方案的一部分运行,该解决方案使用配置服务器作为配置存储,使用 GIT 作为源。我已经看到 npm 与 spring 配置服务器集成的库。
因此,我在这里寻找最佳实践,在 k8s 或 openshift 等编排工具中外部化 Nodejs 中的配置的最佳方法是什么。或者我们可以在上述场景中使用配置服务器吗?
请告知任何信息,任何指示都将受到高度赞赏。
git node.js openshift spring-boot spring-cloud-config-server
我正在配置新的spring config server并收到以下错误。
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Run Code Online (Sandbox Code Playgroud)
我已尝试以下链接,但没有运气
Spring Cloud Config Server 配置与本地存储库
spring config server- 用于本地 git 存储库
https://medium.com/@danismaz.furkan/spring-cloud-config-with-file-system-后端-c18ae16b7ad5
bootstrap.properties
server.port = 8888
spring.cloud.config.server.native.search-locations=file:///C:/configprop/
Run Code Online (Sandbox Code Playgroud)
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> …Run Code Online (Sandbox Code Playgroud) java spring-boot spring-cloud spring-cloud-config spring-cloud-config-server
我有一台 spring 配置服务器,但我将存储库更改为私有服务器,并且我正在尝试使用 SSH 身份验证。
我的 application.yml 是这样的:
spring:
cloud:
config:
server:
git:
uri: git@github.com:server/repo.git
ignoreLocalSshSettings: true
hostKey: githostkey
hostKeyAlgorithm: ssh-rsa
strictHostKeyChecking: true
passphrase: passphrase
privateKey : |
-----BEGIN RSA PRIVATE KEY-----
...............................
-----END RSA PRIVATE KEY-----
Run Code Online (Sandbox Code Playgroud)
但当配置服务器尝试连接到存储库时,我收到此错误:
"org.eclipse.jgit.errors.NoRemoteRepositoryException:
git@github.com:server/repo.git: ERROR: You're using an RSA key with SHA-1, which is
no longer allowed. Please use a newer client or a different key type."
Run Code Online (Sandbox Code Playgroud)
Spring Cloud 文档在这里
建议使用“ssh-keygen -m PEM -t rsa -b 4096 -f ~/config_server_deploy_key.rsa”以正确的格式创建密钥对,我将公钥添加到我的 github 存储库中的 SSH 密钥中。 …