java - 微服务 - 启动配置服务器 org.springframework.boot.context.properties.bind.BindResult 时出错
问题描述
尝试启动配置服务器时出现以下错误。看起来不正确的 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);
}
}
解决方案
推荐阅读
- admob - 在您的 admob 帐户中拥有编辑权限
- html - CSS“内容”属性,你能把两部分的文本连接起来吗?
- c# - 在解决方案探索中更改项目的显示名称
- reactjs - 使用 graphql 和 django 进行分页
- x509certificate - windows server 2012 导入证书失败
- r - 如何在具有随机效应的泊松模型中计算粗略和调整后的发生率?
- nlp - 在 pytorch 中保存模型输出
- tensorflow - 使用 Batch Normalization 和 Leaky ReLU 时的神经网络可解释性
- node.js - 如何解决我的 MERN 应用程序中的 Access-Control-Allow-Origin CORS 错误以进行 MSAL 身份验证?
- javascript - 如何阻止响应式表单验证器不在 OnInit 上触发?