0

尝试启动配置服务器时出现以下错误。看起来不正确的 jar 版本请有任何建议

错误

 Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.cloud.config.server.composite.CompositeEnvironmentBeanFactoryPostProcessor.bindProperties(CompositeEnvironmentBeanFactoryPostProcessor.java:81)

The following method did not exist:

    'java.lang.Object org.springframework.boot.context.properties.bind.BindResult.orElseCreate(java.lang.Class)'

The method's class, org.springframework.boot.context.properties.bind.BindResult, is available from the following locations:

    *jar:file:/C:/Users/GOPU/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.4.0-M1/503562062a9baee246bb7311526d08d16ae05758/spring-boot-2.4.0-M1.jar!/org/springframework/boot/context/properties/bind/BindResult.class*

The class hierarchy was loaded from the following locations:

    org.springframework.boot.context.properties.bind.BindResult: file:/C:/Users/GOPU/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.4.0-M1/503562062a9baee246bb7311526d08d16ae05758/spring-boot-2.4.0-M1.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.context.properties.bind.BindResult

构建.gradle

plugins {
    id 'org.springframework.boot' version '2.4.0-M1'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}

group = 'com.cloud'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '13'

repositories {
    mavenCentral()
    maven { url 'https://repo.spring.io/milestone' }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.cloud:spring-cloud-config-server'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.boot:spring-boot-starter'
}

dependencyManagement {
    imports {
        mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Hoxton.RELEASE'
    }
}

test {
    useJUnitPlatform()
}

主文件

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.config.server.EnableConfigServer;

@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class ConfigApplication {

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

}
4

0 回答 0