spring-cloud-config

No spring.config.import property has been defined


While creating Spring Boot cloud config application getting below error. Any help on this?

No spring.config.import property has been defined
 
Action:

Add a spring.config.import=configserver: property to your configuration.   
If configuration is not required add spring.config.import=optional:configserver: instead.
To disable this check, set spring.cloud.config.enabled=false or 
spring.cloud.config.import-check.enabled=false.

Solution

  • Solution for Maven

    Add the below dependency in the pom.xml file:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-bootstrap</artifactId>
    </dependency>
    

    Solution for Gradle

    Add in the build.gradle file:

    implementation('org.springframework.cloud:spring-cloud-starter-bootstrap')
    

    That resolved my issue.