我正在尝试使用@Retryable调用 REST 模板的方法。如果由于通信错误而返回错误,我想重试,否则我只想在调用时抛出异常。
当 ApiException 发生时,而不是被 @Retryable 抛出和忽略,我收到了ExhaustedRetryException一个关于没有找到足够的“可恢复的”(即@Recover方法)的抱怨。
我想我会看看是否仅仅拥有可恢复的方法可能会让它快乐并且仍然按预期执行。没那么多。它没有抛出异常,而是调用了可恢复的方法。
@Retryable(exclude = ApiException include = ConnectionException, maxAttempts = 5, backoff = @Backoff(multiplier = 2.5d, maxDelay = 1000000L, delay = 150000L))
Object call(String domainUri, ParameterizedTypeReference type, Optional<?> domain = Optional.empty(), HttpMethod httpMethod = HttpMethod.POST) throws RestClientException {
RequestEntity request = apiRequestFactory.createRequest(domainUri, domain, httpMethod)
log.info "************************** Request Entity **************************"
log.info "${request.toString()}"
ResponseEntity response
try {
response = restTemplate.exchange(request, type)
log.info "************************** Response Entity **************************"
log.info "${response.toString()}"
} …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Boot,并且有一个定义一些端点的 Yaml 文件。我需要为其中一个端点设置别名以拥有不同的端点,但功能完全相同。
举个例子,如果我有一个规范如下:
openapi: '3.0.1'
servers:
- url: 'http://localhost:8080/api
paths:
/v3/users
.... (remainder of endpoint spec)
Run Code Online (Sandbox Code Playgroud)
根据我所读到的内容,我想补充的是:
/globalusers/v3/users
$ref: '#/paths/~1v3~1users
Run Code Online (Sandbox Code Playgroud)
当我这样做时,生成的 Spring API 不包含新的 RequestMapping。我尝试复制整个/v3/users定义并将其也放入其中,但没有任何变化。
要么我遗漏了一些东西,要么误解了我读到的内容。感谢所有帮助!
谢谢。
我正在遵循 Spring Rest Docs 参考文档中关于构建配置的说明。但是当我尝试做时,“片段”属性似乎没有暴露给 Asciidoctor
include::{snippets}/....
Run Code Online (Sandbox Code Playgroud)
但我得到一个 asciidoctor“警告:删除包含对缺失属性的引用的行:片段”
如果我去掉属性引用,直接放在路径中,就会出现包含文件的内容。
这是包含 Rest Docs/Asciidoctor 信息的 build.gradle 文件:
buildscript {
ext {
springBootVersion = '1.3.0.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id "org.asciidoctor.convert" version "1.5.3"
}
allprojects {
apply plugin: 'groovy'
apply plugin: 'idea'
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'com....'
ext {
si = [version: '4.1.7.RELEASE']
groovy = [version: '2.4.5']
newRelic = [version: '3.13.0']
jackson = [version: '2.6.2']
}
repositories {
mavenCentral()
maven …Run Code Online (Sandbox Code Playgroud)