Spring Cloud Config Server 配置与本地存储库 [英] Spring Cloud Config Server configuration with local repository

查看:30
本文介绍了Spring Cloud Config Server 配置与本地存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用后端存储库(文件系统)设置 Spring Cloud Config Server,但端点(http://localhost:8888/licensingservice/default)返回以下内容:

I'm trying to set up Spring Cloud Config Server with backend repository (filesystem), but the endpoint(http://localhost:8888/licensingservice/default) returns the following:

{"name":"licensingservice","profiles":["default"],"label":null,"version":null,"state":null,"propertySources":[]}

主要内容:

@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

application.yml:

The application.yml:

server:
   port: 8888
spring:
   profiles:
      active: native
    cloud:
       config:
          server:
             native:
                searchLocations: file:///Users/josedavi/Desenvolvimento/WorkSpace/Pessoal/sample-spring-microservices/sample-spring-microservices/config-server/src/main/resources/config

许可服务.yml:

tracer.property: "I AM THE DEFAULT"
spring.jpa.database: "POSTGRESQL"
spring.datasource.platform: "postgres"
spring.jpa.show-sql: "true"
spring.database.driverClassName: "org.postgresql.Driver"
spring.datasource.url: "jdbc:postgresql://database:5432/eagle_eye_local"
spring.datasource.username: "postgres"
spring.datasource.password: "p0stgr@s"
spring.datasource.testWhileIdle: "true"
spring.datasource.validationQuery: "SELECT 1"
spring.jpa.properties.hibernate.dialect: "org.hibernate.dialect.PostgreSQLDialect"

服务配置路径:

C:\Users\josedavi\Desenvolvimento\WorkSpace\Pessoal\sample-spring-microservices\sample-spring-microservices\config-server\src\main\resources\config

项目:https://github.com/jdavid-araujo/sample-spring-microservices

推荐答案

在配置服务的 application.yml 中添加以下格式:

Add the following format in your application.yml of config service:

[classpath:/, classpath:/config, classpath:/config/{application}, classpath:/config/{application}/{profile}]

[classpath:/, classpath:/config, classpath:/config/{application}, classpath:/config/{application}/{profile}]

上述格式从 config 文件夹中搜索位​​置,下一个带有 application 名称、application 名称和 profile 的文件夹分别.

The above format search locations from config folder, next folder with application name, application name and profile respectively.

spring:
   profiles:
      active: native
   cloud:
       config:
          server:
             native:
                searchLocations: "[classpath:/, classpath:/config, classpath:/config/{application}, classpath:/config/{application}/{profile}]"

这篇关于Spring Cloud Config Server 配置与本地存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆