无法从配置服务器获取属性值

9vw9lbht  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(216)

我在这里学习SpringBootV.2.3.9.release+microservices项目-https://www.youtube.com/watch?v=z7a_m8hkjg0
在本例中,我无法使用spring cloud config从属性文件中获取详细信息。
spring配置服务器
应用程序.yml

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

server:
  port: ${port:8888}

配置服务器应用程序.java

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {

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

}

物业接入服务
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;
}

PropertyAccess服务应用程序.java

@SpringBootApplication
public class PropertyAccessServiceApplication {

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


暂无答案!

目前还没有任何答案,快来回答吧!

相关问题