Unable to fetch property value from the config server
Asked Answered
P

1

1

I am learning Spring Boot v.2.3.9.RELEASE + Microservices project from here - https://www.youtube.com/watch?v=Z7A_M8HkJG0

In this example, I am unable to fetch the details from the properties file using spring-cloud-config.

spring-config-server

application.yml

spring:
  application:
    name: config-server
  cloud:
    config:
      server:
        git:
          uri: https://github.com/techefx/environment-variable-repo.git

server:
  port: ${port:8888}

ConfigServerApplication.java

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {

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

}

property-access-service

PropertyAccessBean.java

@Component
@ConfigurationProperties(prefix = "property-file")
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PropertyAccessBean {
    private String name;
    private String description;
}

PropertyAccessValue.java

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PropertyAccessValue {
    private String name;
    private String description;
}

PropertyAccessServiceApplication.java

@SpringBootApplication
public class PropertyAccessServiceApplication {

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

enter image description here

enter image description here

Prognostication answered 2/4, 2021 at 16:58 Comment(2)
You need getter and setter for PropertyAccessBean's fieldsRetharethink
@Md.KawserHabib - Hey, Thanks, I have added lambok annotation - data already, that gives me setter and getter, but issue is somethingPrognostication
P
1

put (default-label: main) in yml file:

spring: application: name: techefx-spring-cloud-config-server cloud: config: server: git: uri: https://github.com/techefx/environment-variable-repo.git default-label: main

server: port: ${port:8888}

Pottle answered 20/6, 2021 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.