Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Não carrega arquivo do fornecedor

Olá pessoal, não estou conseguindo carregar o arquivo fornecedor.yml A aplicação roda e sobre o ConfigServer certinho na porta 8888, mas quando dou um get no postman recebo um server error: http://localhost:8888/fornecedor/default

{
    "timestamp": "2020-11-30T02:58:58.759+00:00",
    "status": 500,
    "error": "Internal Server Error",
    "message": "",
    "path": "/fornecedor/default"
}

aplication.yml (c:/microservice-repo)

server:
  port: 8888

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: c:/microservice-repo

ConfigServerApplication.java

package br.com.alura.microservice.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {

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

}

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.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>br.com.alura.microservice.config</groupId>
    <artifactId>ConfigServer</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>ConfigServer</name>
    <description>ALURA - Microservicos - Config</description>

    <properties>
        <java.version>11</java.version>
        <spring-cloud.version>2020.0.0-M5</spring-cloud.version>
    </properties>

    <dependencies>
        <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>
                <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>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

</project>
2 respostas

Mudei o search-locations, agora ele encontrou o arquivo mas não mostra os dados, o propertySources vem vazio...

server:
  port: 8888

spring:
  profiles:
    active: native
  cloud:
    config:
      server:
        native:
          search-locations: =file:/E:/microservice-repo
          # =file:///E:/microservice-repo

Resultado do Postman na url: http://localhost:8888/fornecedor/default

{
    "name": "fornecedor",
    "profiles": [
        "default"
    ],
    "label": null,
    "version": null,
    "state": null,
    "propertySources": []
}
solução!

Refiz toda a parte do config server e funcionou, não sei como... \o/