首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未识别字段在: jerseyClient下拉向导yml?

问未识别字段在: jerseyClient下拉向导yml?
EN

Stack Overflow用户
提问于 2019-02-26 11:26:15
回答 1查看 237关注 0票数 2

我的下拉向导服务器需要调用外部REST资源,为此,我计划使用泽西客户端,为此,我在pom.xml中添加了以下依赖项:

代码语言:javascript
复制
<dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-client</artifactId>
            <version>1.4.0-SNAPSHOT</version>
        </dependency>

然后,我按照以下方式添加了yml配置:

代码语言:javascript
复制
jerseyClient:
  minThreads: 1
  maxThreads: 128
  workQueueSize: 8
  gzipEnabled: true
  gzipEnabledForRequests: true
  chunkedEncodingEnabled: true

在我的WebConfiguration类中,我添加了以下代码:

代码语言:javascript
复制
@Valid
    @NotNull
    private JerseyClientConfiguration jerseyClient = new JerseyClientConfiguration();

    @JsonProperty("jerseyClient")
    public JerseyClientConfiguration getJerseyClientConfiguration() {
        return this.jerseyClient;
    }

当我尝试运行我的WebApplication时,我会得到以下错误:

代码语言:javascript
复制
api.yml has an error:
  * Unrecognized field at: jerseyClient
    Did you mean?:
      - server
      - assets
      - logging
      - metrics
      - database
        [1 more]


Process finished with exit code 1

这里怎么了?是否不允许在下拉向导服务器上使用下拉向导客户端?还是简单的压痕问题?

更新:

在添加jerseyClient配置失败后,我尝试添加HttpClient,它为我工作。

EN

回答 1

Stack Overflow用户

发布于 2021-08-09 18:25:02

尝试在@JsonProperty扩展文件中添加setter with Configuration扩展文件。

这对我有用。

在Configration文件中

代码语言:javascript
复制
@Valid
@NotNull
private JerseyClientConfiguration jerseyClient = new JerseyClientConfiguration();

@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
    return jerseyClient;
}

@JsonProperty("jerseyClient")
public void setJerseyClientConfiguration(JerseyClientConfiguration jerseyClient) {
    this.jerseyClient = jerseyClient;
}

在config.yml文件中。

代码语言:javascript
复制
jerseyClient:
  minThreads: 2
  maxThreads: 128
  workQueueSize: 8
  gzipEnabled: true
  gzipEnabledForRequests: true
  chunkedEncodingEnabled: true
server:
  applicationConnectors:
    - type: http
      port: 8085
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54884455

复制
相关文章

相似问题

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