我想在应用程序的开发阶段将 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/