无法从配置服务器获取属性值 [英] Unable to fetch property value from the config server
问题描述
我正在从这里学习 Spring Boot v.2.3.9.RELEASE + 微服务项目 -
put (default-label: main) in yml file:
春天:应用:名称:techefx-spring-cloud-config-server云:配置:服务器:吉特:uri:https://github.com/techefx/environment-variable-repo.git默认标签:主要
服务器:端口:${port:8888}
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);
}
}
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}
这篇关于无法从配置服务器获取属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!