java - Spring Cloud git 配置——将存储库放在直接包含类路径的文件夹中?

标签 java spring git cloud spring-cloud

我想在应用程序的开发阶段将 git 存储库放在类路径正上方的文件夹中。

目前,我将其作为我的 Spring Cloud git URI:

spring.cloud.config.server.git.uri=file://${user.dir}/cloud-configuration-repository

此 URI 指向类路径正上方的文件夹。

但是,我在运行时遇到了这个错误。

***************************
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.

编辑:这是我希望拥有的项目结构:

Project
├── _.idea
├── src
|   ├── main
|   └── test
├── target
└── cloud-configuration-repository

最佳答案

来自文档:

https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html

2.1.3 文件系统后端: 配置服务器中还有一个“ native ”配置文件,它不使用 Git,而是从本地类路径或文件系统加载配置文件 (您想使用 spring.cloud.config.server.native.searchLocations 指向的任何静态 URL)。要使用 native 配置文件,请使用 spring.profiles.active=native 启动配置服务器。

因此,在您的情况下,它将是:

spring.profiles.active=native
spring.cloud.config.server.native:searchLocations=file://${user.dir}/cloud-configuration-repository

关于java - Spring Cloud git 配置——将存储库放在直接包含类路径的文件夹中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53787325/

相关文章:

java - 如何让 CXF 将异常记录到 ERROR channel ?

git - 使用 git 子模块还原 Nuget 包

java - 何时使用 Android 的 ArrayMap 而不是 HashMap?

java - 测试 Google Play 安装引荐库

java - spring webflux中Controller层错误处理错误

git - 按分支名称对 `git branch --all` 中的分支进行排序

git - 如何将(未推送的)提交从一个分支移动到另一个分支

java - 如果我在构造函数中抛出新的异常,那么每当我使用此构造函数时都必须捕获此异常吗?

java - spring-mvc 不会将我的请求参数绑定(bind)到 int

javascript - 使用 Spring MVC 将值从 AJAX 传递到 Controller