cannot resolve configuration property 'eureka.client.serviceUrl.defaultZone'

       Write micro-services when eureka client registration services yml also introduced also related configuration all configuration Ok, the strange thing is that the client service started successfully all interfaces ip can normally access but has been unable to register EurekaServer center, the same configuration in other the project is good. Then application.yml file has been prompted "can not resolve configuration property 'eureka.client.serviceUrl.defaultZone' more ... (Ctrl + F1)", Eureka related properties all tips

 Cause: configure attributes you not found

solution:

First, delete the relevant dependent Eureka, recompile and then re-add recompile (this method tried many times not so that)

Second, with reference to the official website https://docs.spring.io/spring-boot/docs/2.1.1.RELEASE/reference/html/configuration-metadata.html#configuration-metadata-annotation-processor adding configure the identification attribute (use this the method is Ok)

1, add the relevant dependent

  •       gradle project dependencies
compileOnly "org.springframework.boot:spring-boot-configuration-processor"
  • maven project depend on the introduction of
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <version>2.1.3.RELEASE</version>
</dependency>

2, in resoures / META-INF file folder add additional-spring-configuration-metadata.json, as follows

{
  "properties": [
    {
      "name": "eureka.client.serviceUrl.defaultZone",
      "type": "java.lang.String",
      "description": "Description for eureka.client.serviceUrl.defaultZone."
  }
] }

3, introduced in application.java add the file attributes related notes @ConfigurationProperties

4, start again compiled discovery services registered a success

发布了21 篇原创文章 · 获赞 8 · 访问量 40万+

Guess you like

Origin blog.csdn.net/qq_31150503/article/details/87627108