小编buf*_*low的帖子

使用Spring进行精确的RequestMapping

我在春天有以下内容

@RequestMapping("/hello")
Run Code Online (Sandbox Code Playgroud)

但是Spring会自动为/ hello /和/hello.*添加映射.如何进行精确的URL匹配?

只有/你好应该工作,其他任何东西都应该404

java spring

7
推荐指数
1
解决办法
2505
查看次数

application.properties 中的 Kafka ErrorHandlingDeserializer2 配置值

我想使用 spring boot 自动配置在 application.properties 中设置 Kafka ErrorHandlingDeserializer2 配置值,而不是在如下代码中定义它们:

... // other props
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ErrorHandlingDeserializer.class);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ErrorHandlingDeserializer.class);
props.put(ErrorHandlingDeserializer.KEY_DESERIALIZER_CLASS, JsonDeserializer.class);
props.put(JsonDeserializer.KEY_DEFAULT_TYPE, "com.example.MyKey")
props.put(ErrorHandlingDeserializer.VALUE_DESERIALIZER_CLASS, JsonDeserializer.class.getName());
props.put(JsonDeserializer.VALUE_DEFAULT_TYPE, "com.example.MyValue")
props.put(JsonDeserializer.TRUSTED_PACKAGES, "com.example")
return new DefaultKafkaConsumerFactory<>(props); 
Run Code Online (Sandbox Code Playgroud)

我正在做的是在 application.properties 中设置配置值,如下所示,尝试使用 spring boot 自动配置:

spring.kafka.consumer.key-deserializer=org.springframework.kafka.support.serializer.ErrorHandlingDeserializer2
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.ErrorHandlingDeserializer2
spring.deserializer.key.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer
spring.deserializer.value.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

ConsumerConfig values: 
    auto.commit.interval.ms = 5000
    auto.offset.reset = latest
    bootstrap.servers = [abc1.xyz.def.dev:9092, abc2.xyz.def.dev:9092, abc3.xyz.def.dev:9092]
    check.crcs = true
    client.id = 
    connections.max.idle.ms = 540000
    default.api.timeout.ms = 60000
    enable.auto.commit = true
    exclude.internal.topics = true
    fetch.max.bytes = 52428800
    fetch.max.wait.ms = 500
    fetch.min.bytes = 1 …
Run Code Online (Sandbox Code Playgroud)

java error-handling apache-kafka spring-boot spring-kafka

3
推荐指数
1
解决办法
3753
查看次数