简体   繁体   English

无法识别的字段:jerseyClient dropwizard yml?

[英]Unrecognized field at: jerseyClient dropwizard yml?

My dropwizard server needs to call external REST resource, for that, I plan to use Jersey Client, For that, I have added following dependencies in my pom.xml:我的 dropwizard 服务器需要调用外部 REST 资源,为此,我计划使用 Jersey 客户端,为此,我在 pom.xml 中添加了以下依赖项:

<dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-client</artifactId>
            <version>1.4.0-SNAPSHOT</version>
        </dependency>

Then I added yml configurations as follows:然后我添加了yml配置如下:

jerseyClient:
  minThreads: 1
  maxThreads: 128
  workQueueSize: 8
  gzipEnabled: true
  gzipEnabledForRequests: true
  chunkedEncodingEnabled: true

In my WebConfiguration class I added the following code:在我的WebConfiguration类中,我添加了以下代码:

@Valid
    @NotNull
    private JerseyClientConfiguration jerseyClient = new JerseyClientConfiguration();

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

When I try running my WebApplication I get the following error:当我尝试运行我的 WebApplication 时,我收到以下错误:

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

What is wrong here ?这里有什么问题? Is the dropwizard client not allowed on dropwizard server ? dropwizard 服务器是否不允许 dropwizard 客户端? Or it's simply indentation problem ?或者它只是缩进问题?

Update:更新:

After failing to add jerseyClient configuration I tried adding HttpClient it worked for me.在添加 jerseyClient 配置失败后,我尝试添加HttpClient它对我有用。

Try to add setter for with @JsonProperty in Configuration extended file.尝试在Configuration扩展文件中为@JsonProperty添加 setter。

This worked for me.这对我有用。

In Configration fileConfigration文件中

@Valid
@NotNull
private JerseyClientConfiguration jerseyClient = new JerseyClientConfiguration();

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

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

In config.yml file.config.yml文件中。

jerseyClient:
  minThreads: 2
  maxThreads: 128
  workQueueSize: 8
  gzipEnabled: true
  gzipEnabledForRequests: true
  chunkedEncodingEnabled: true
server:
  applicationConnectors:
    - type: http
      port: 8085

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM