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);
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…