8

How to fix this error?

Here is it:

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata

And here is my pom.xml file

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>2.5.4</version>
   <relativePath/>
</parent>
<groupId>io.x</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka-server</name>
<description>Eureka server</description>
<properties>
   <java.version>16</java.version></docker.artifact.version>
   <spring-cloud-starter-eureka-server.version>1.4.7.RELEASE</spring-cloud-starter-eureka-server.version>
</properties>
<dependencies>
   <dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter</artifactId>
   </dependency>

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

   <dependency>
       <groupId>org.springframework.cloud</groupId>
       <artifactId>spring-cloud-starter-eureka-server</artifactId>
       <version>${spring-cloud-starter-eureka-server.version}</version>
   </dependency>
</dependencies>
<dependencyManagement>
   <dependencies>
       <dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-dependencies</artifactId>
           <version>Hoxton.SR12</version>
           <type>pom</type>
           <scope>import</scope>
       </dependency>
   </dependencies>
</dependencyManagement>
João Dias
  • 16,277
  • 6
  • 33
  • 45
Arthur
  • 575
  • 3
  • 8
  • 16
  • I think you have incompatible dependencies, spring-boot ver `2.5.4` and `spring-cloud-starter-eureka-server` version `1.4.7.RELEASE` – pleft Sep 02 '21 at 13:11
  • @pleft org.springframework.cloud spring-cloud-starter-netflix-eureka-server - same error – Arthur Sep 02 '21 at 13:25
  • 1
    Hoxton isn't compatible with boot 2.5 afaik only unto 2.3. Use the 2020.0.3 version instead for 2.4 and higher compatibility. – M. Deinum Sep 02 '21 at 13:35
  • 1
    you can find the compatible version from here:https://spring.io/projects/spring-cloud @Artthur – Dolphin Nov 21 '21 at 10:37

3 Answers3

16

You are using Spring Boot 2.5.4 with Spring Cloud Hoxton.SR12.

As stated in the Spring Cloud compatibility matrix here, Spring Cloud Hoxton.SR12 is compatible with Spring Boot 2.2.x, 2.3.x. So you have to choose the right combination.

If you want to simplify the version choosing, you can use the Spring Initializr tool.

thepaoloboi
  • 708
  • 4
  • 13
1

Try (or adapt yours as) the following pom.xml:

<?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>16</java.version>
        <spring-cloud.version>2020.0.3</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        </dependency>

        <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>
pleft
  • 7,567
  • 2
  • 21
  • 45
0

Use spring version in pom.xml:

  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
  </parent>

   <properties>
        <java.version>11</java.version>
        <spring-cloud.version>Greenwich.SR2</spring-cloud.version>
   </properties>

     <dependencies>   

    <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
            <version>2.0.0.RELEASE</version>
    </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>
Maninder
  • 1,539
  • 1
  • 10
  • 12