gpt4 book ai didi

java - 在 Dropwizard 中启用 Gzip 压缩

转载 作者:行者123 更新时间:2023-11-29 03:18:24 25 4
gpt4 key购买 nike

我有一个 REST 服务,我正在使用 dropwizard 0.6.2。

pom代码如下

    <dependency>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>0.6.2</version>
</dependency>

我正在使用 config.yml 文件。启动服务代码如下

new BrAnalyticsNoSQLControllerService().run(new String[] { "server","src\\main\\java\\config.yml"});

根据 dropwizard 文档,我尝试在 config.yml 中添加以下代码以启用 gzip

gzip:
enabled: true
minimumEntitySize: 256B
bufferSize: 8KB

但是当我尝试运行我的服务时出现以下错误,

Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "gzip" (class com.Breezom.BrAnalyticsNoSQLController.REST.Config.BrAnalyticsNoSQLController), not marked as ignorable (7 known properties: , "mongodb", "mongoport", "loggingConfiguration", "http", "mongohost", "httpConfiguration", "logging"]) at [Source: N/A; line: -1, column: -1] (through reference chain: com.Breezom.BrAnalyticsNoSQLController.REST.Config.BrAnalyticsNoSQLController["gzip"]) at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79) at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:579) at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:672) at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:906) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:328) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121) at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:2765) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:1478) at com.yammer.dropwizard.config.ConfigurationFactory.build(ConfigurationFactory.java:63) at com.yammer.dropwizard.config.ConfigurationFactory.build(ConfigurationFactory.java:48) at com.yammer.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:83) at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:51) at com.yammer.dropwizard.cli.Cli.run(Cli.java:53) at com.yammer.dropwizard.Service.run(Service.java:61) at com.Breezom.BrAnalyticsNoSQLController.REST.Service.BrAnalyticsNoSQLControllerService.main(BrAnalyticsNoSQLControllerService.java:162)

我无法弄清楚问题是什么。

提前致谢!

最佳答案

尝试更改您的 YAML 以包含 http: 部分,如下所示:

http:
gzip:
enabled: true
minimumEntitySize: 256B
bufferSize: 8KB

关于java - 在 Dropwizard 中启用 Gzip 压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25119902/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com