gpt4 book ai didi

spring-boot - 升级到2.2.4后无法运行Spring Boot应用程序:方法不存在

转载 作者:行者123 更新时间:2023-12-03 05:29:09 25 4
gpt4 key购买 nike

将Spring Boot版本从2.1.11升级到2.2.4后出现错误。然后,我将spring-cloud-starter-openfeign从2.0.2升级到2.2.1,但这没有帮助。

以下方法不存在:

'org.springframework.boot.web.client.RestTemplateBuilder org.springframework.boot.web.client.RestTemplateBuilder.setConnectTimeout(int)'

该方法的类org.springframework.boot.web.client.RestTemplateBuilder可从以下位置获得:
jar:file:/C:/Users/a/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.2.4.RELEASE/225a4fd31156c254e3bb92adb42ee8c6de812714/spring-boot-2.2.4.RELEASE.jar!/org/springframework/boot/web/client/RestTemplateBuilder.class

它是从以下位置加载的:
file:/C:/Users/a/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/2.2.4.RELEASE/225a4fd31156c254e3bb92adb42ee8c6de812714/spring-boot-2.2.4.RELEASE.jar

调用该方法的尝试发生在自定义类的构造函数中
 this.restTemplate = restTemplateBuilder.setConnectTimeout(props.getConnectTimeoutMs()).setReadTimeout(props.getReadTimeoutMs()).build();

build.gradle:
buildscript {
repositories {...
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.4.RELEASE")
classpath('gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.17.2')
classpath('org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:2.2.1')
}
}

plugins {
id "org.sonarqube" version "2.6.2"
id "com.jfrog.artifactory" version "4.6.2"
}

apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.palantir.docker'
apply plugin: 'org.unbroken-dome.test-sets'

sourceCompatibility = 11

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

configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
exclude group: 'ch.qos.logback", module: "logback-classic'
exclude group: 'ch.qos.logback", module: "logback-core'
}

dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('javax.xml.bind:jaxb-api:2.3.0')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.cloud:spring-cloud-starter-openfeign:2.2.1.RELEASE')
compile('io.github.openfeign:feign-jackson:10.7.4')
compile("org.togglz:togglz-spring-boot-starter:2.6.1.Final")
compile('org.springframework.retry:spring-retry:1.2.2.RELEASE')
runtime('io.micrometer:micrometer-registry-prometheus:1.3.2')
compileOnly("org.projectlombok:lombok:1.18.6")
annotationProcessor("org.projectlombok:lombok:1.18.6")
compile("org.mapstruct:mapstruct:1.3.0.Final")
annotationProcessor("org.mapstruct:mapstruct-processor:1.3.0.Final")
compile('com.microsoft.azure:azure-servicebus:1.2.12')
compile("io.springfox:springfox-swagger2:2.9.2")
compile("io.springfox:springfox-swagger-ui:2.9.2")
compile('org.apache.commons:commons-io:1.3.2')
compile("com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.2")
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.2")
compile('org.apache.commons:commons-lang3:3.7')
compile('commons-validator:commons-validator:1.6')
compile('org.apache.httpcomponents:httpclient:4.5.8')
compile('org.springframework.boot:spring-boot-starter-log4j2')
testCompile('org.testcontainers:spock:1.12.4')
testCompile('org.codehaus.groovy:groovy-all:2.5.8')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile("org.spockframework:spock-core:1.3-groovy-2.5")
testCompile("org.spockframework:spock-spring:1.3-groovy-2.5")
testCompile('nl.jqno.equalsverifier:equalsverifier:3.1.10')
compile('com.microsoft.azure:azure:1.20.1')
testAnnotationProcessor("org.projectlombok:lombok:1.18.6")
testCompile('com.github.tomakehurst:wiremock:2.15.0')
testCompile('com.github.tomjankes:wiremock-groovy:0.2.0')
testCompile('com.rabbitmq:amqp-client:5.2.0')
}

最佳答案

分别查看2.1.112.2.4版本的Javadoc。较早的版本仍使用int参数公开此方法,但已声明已弃用,而应改用java.time.Duration

2.2.4中仍然存在接受java.time.Duration的方法,您应该改用该方法。

关于spring-boot - 升级到2.2.4后无法运行Spring Boot应用程序:方法不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60088195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com