小编OCP*_*CPi的帖子

如何修复 Spring 中的 JSON 解码错误?

我正在通过包含一组对象的 REST 发送一个用户SimpleGrantedAuthority对象。在接收方,我遇到了一个例外:

org.springframework.core.codec.DecodingException:JSON 解码错误:无法构造实例 org.springframework.security.core.authority.SimpleGrantedAuthority (尽管至少存在一个创建者):无法从对象值反序列化(没有基于委托或属性的创建者);

我正在使用 Spring Boot 2.1.2 提供的默认 JSON 映射器。在接收方,我使用 WebFlux 的 WebClient(在本例中为 WebTestClient)。

任何人都可以向我解释为什么我会收到此错误以及如何解决它?

java spring jackson spring-webflux

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

Spring Boot 2.2.2 - Prometheus 在 Actuator 中不起作用

我已将 Spring Boot 应用程序升级到最新的 2.2.2 Boot 版本。从那以后,我只有一个指标端点,但没有 Prometheus。

我的build.gradle.kts文件具有org.springframework.boot:spring-boot-starter-actuator依赖项,我还添加io.micrometer:micrometer-registry-prometheus了参考建议(Prometheus 端点)。

我的application.yml如下所示:

management:
  server:
    port: 9000
  endpoints:
    web:
      exposure:
        include: health, shutdown, prometheus
  endpoint:
    shutdown:
      enabled: true
Run Code Online (Sandbox Code Playgroud)

有人可以指导我走向正确的方向吗?

编辑:它在 Spring Boot 2.2.0 中工作。这是下载相同项目的链接链接

编辑 2:我可以验证它也适用于 2.2.1。

spring-boot spring-boot-actuator prometheus

3
推荐指数
2
解决办法
5517
查看次数

使用 Micrometer 和 WebFlux 测量执行时间

我想测量一些使用 WebFlux 进行的异步调用的长度。我一直在阅读各种来源,因为我了解@Timed注释正在与 AspectJ 一起使用,并且基本上只是在方法调用之前启动一个计时器并在之后停止它。这显然不适用于异步方法。

有没有针对 WebFlux 的解决方案,或者我唯一能做的就是传递执行时间戳,使我的应用程序逻辑混乱?

project-reactor spring-webflux micrometer spring-micrometer

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