首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >升级到2.2.4: method后无法运行Spring应用程序

升级到2.2.4: method后无法运行Spring应用程序
EN

Stack Overflow用户
提问于 2020-02-06 05:23:34
回答 2查看 1.2K关注 0票数 0

在将Spring版本从2.1.11升级到2.2.4后,我得到了一个错误。然后,我将openfeign从2.0.2升级到2.2.1,但这并没有帮助。

不存在以下方法:

代码语言:javascript
复制
'org.springframework.boot.web.client.RestTemplateBuilder org.springframework.boot.web.client.RestTemplateBuilder.setConnectTimeout(int)'

该方法的类org.springframework.boot.web.client.RestTemplateBuilder,可从以下位置获得:

代码语言:javascript
复制
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

它从以下位置加载:

代码语言:javascript
复制
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

调用方法的尝试发生在自定义类的构造函数中

代码语言:javascript
复制
 this.restTemplate = restTemplateBuilder.setConnectTimeout(props.getConnectTimeoutMs()).setReadTimeout(props.getReadTimeoutMs()).build();

build.gradle:

代码语言:javascript
复制
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')
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-02-06 06:33:38

分别查看2.1.112.2.4版本的Javadoc。旧版本仍然公开了这个使用int参数的方法,但是已经声明了它是不推荐的,您应该使用java.time.Duration

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

票数 0
EN

Stack Overflow用户

发布于 2020-02-06 06:35:27

似乎setConnectTimeout(int connectTimeout)已被废弃,而setConnectTimeout(Duration connectTimeout)则是added.Please,尝试添加以下内容

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60088195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档