I tried to recreate your pom.xml via Spring Initializr and the following pom.xml manages to start the SpringBootApplication successfully.
You can cross-check it with yours, just some quick points:
spring-boot-starteris not needed since you havespring-boot-starter-webspring-cloud-starter-bootstrapis not required (at least Spring Initializr didn't put it along withspring-cloud-starter-configI didn't include
spring-batch-testandspring-security-testsince it doesn't seem that you use the relevant starters.<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.4</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>11</java.version> <spring-cloud.version>2020.0.3</spring-cloud.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency> <!-- runtime dependencies --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <!-- test dependencies --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
Moreover it needed to add the following line in the appplication.properties file:
spring.config.import=optional:configserver:
Answer from pleft on Stack OverflowTo fix it you should declare version of org.springframework.cloud that you are going to use.
To fix it just add next ones in your build.gradle
ext {
set('springCloudVersion', "2022.0.4") // 2022.0.4 is the latest one.
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
Or to your newest dependencies set also version :
implementation 'org.springframework.cloud:spring-cloud-starter-config:4.0.4'
implementation 'org.springframework.cloud:spring-cloud-starter:4.0.4'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:4.0.4'
Also 4.0.4 is the latest one.
add in gradle.properties
springCloudVersion=2025.0.0
add in build.gradle
implementation(platform("org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"))
implementation 'org.springframework.cloud:spring-cloud-starter-config'