![](/img/trans.png)
[英]configuration.yml has an error: * Unrecognized field at: driverClass - DROPWIZARD
[英]Unrecognized field at: jerseyClient dropwizard yml?
我的 dropwizard 服務器需要調用外部 REST 資源,為此,我計划使用 Jersey 客戶端,為此,我在 pom.xml 中添加了以下依賴項:
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-client</artifactId>
<version>1.4.0-SNAPSHOT</version>
</dependency>
然后我添加了yml配置如下:
jerseyClient:
minThreads: 1
maxThreads: 128
workQueueSize: 8
gzipEnabled: true
gzipEnabledForRequests: true
chunkedEncodingEnabled: true
在我的WebConfiguration
類中,我添加了以下代碼:
@Valid
@NotNull
private JerseyClientConfiguration jerseyClient = new JerseyClientConfiguration();
@JsonProperty("jerseyClient")
public JerseyClientConfiguration getJerseyClientConfiguration() {
return this.jerseyClient;
}
當我嘗試運行我的 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
這里有什么問題? dropwizard 服務器是否不允許 dropwizard 客戶端? 或者它只是縮進問題?
更新:
在添加 jerseyClient 配置失敗后,我嘗試添加HttpClient它對我有用。
嘗試在Configuration
擴展文件中為@JsonProperty
添加 setter。
這對我有用。
在Configration
文件中
@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
文件中。
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.