小编Dha*_*pil的帖子

Spring验证与Hibernate验证

我现在很困惑.我知道Hibernate Validator 6是Bean Validation 2.0规范的参考实现.它支持分组,错误消息的国际化,自定义方法验证等.问题是Spring 5是否支持这些功能,还是我只剩下Hibernate Validator 6?

为什么我应该使用Hibernate Validator和我的Sprig Boot项目而不是提供的Spring Validation.我的公司需要使用任何第三方库的理由.

所有在线参考示例都建议使用Hibernate Validator,并且在Spring验证中没有发现任何内容,请建议或指向其他链接.

java validation spring hibernate-validator

12
推荐指数
2
解决办法
7233
查看次数

Spring Kafka 消费者在 LeaveGroup 请求后无法重新加入

我们在重负载的生产中使用 Spring Kafka。我们使用了 @KafkaListener 注释并创建了这些侦听器作为 Spring Boot 服务的一部分。

这些消费者经常向协调器发送 LeaveGroup 请求,然后消费者无限期地挂起/卡住,没有任何日志或错误。在这种情况下,我们剩下的唯一选择是重新部署该特定实例。

这是我们看到的一系列日志:

Attempt to heartbeat failed since group is rebalancing
Attempt to heartbeat failed since group is rebalancing
This member will leave the group because consumer poll timeout has expired. This means the time between subsequent calls to poll() was longer than the configured max.poll.interval.ms, which typically implies that the poll loop is spending too much time processing messages. You can address this either by increasing max.poll.interval.ms or by reducing …
Run Code Online (Sandbox Code Playgroud)

apache-kafka spring-kafka

6
推荐指数
1
解决办法
6687
查看次数

Spring Webflux Security 只允许一个 URL

我想允许在特定控制器中定义的所有 url,除了一个。

假设我的控制器公开了 3 个带有基本 url 的 url /users

  1. "/" 列出所有用户
  2. "/{id}" 按 id 列出用户
  3. "/admin" 获取用户的管理员级别详细信息。

我想允许除最后一个用户之外的任何用户访问 1 和 2 个 url。

我一直在做这样的事情

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
    http.authorizeExchange()
        .pathMatchers("/users/**")
        .permitAll()
        .pathMatchers("/users/admin")
        .hasRole("ADMIN")
        .anyExchange()
        .authenticated()
        .and()
        .httpBasic()
        .and()
        .formLogin();
    return http.build();
}
Run Code Online (Sandbox Code Playgroud)

但它不起作用。我也试过相反的,即

@Bean
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
    http.authorizeExchange()
        .pathMatchers("/users/admin")
        .hasRole("ADMIN")
        .anyExchange()
        .authenticated()
        .pathMatchers("/users/**")
        .permitAll()
        .and()
        .httpBasic()
        .and()
        .formLogin();
    return http.build();
}
Run Code Online (Sandbox Code Playgroud)

这也不起作用,说明因为anyExchange()已注册下一个pathMatcher无法访问。

java spring spring-security spring-webflux

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

如何使R中直方图中y轴的长度更长

我使用以下代码来生成直方图。但是,我想使 y 轴更长,因为它太短了,我可以知道该怎么做吗?

> h<-hist(data, breaks=c(0,1, 2, 3, 4), col="grey",xlim = c(0,4), xlab="",xaxt="n",main="")
> axis(side=1, at=0.5:3.5, labels=c(1,2,3,4))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

r

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