小编Ale*_*mov的帖子

Spring Cloud Stream验证

如何使用标准的基于Spring注释的验证在消息侦听器中使用Spring Cloud Stream框架执行验证?

尝试了不同的情况,@Valid @Payload对于传入的对象,尝试使用@Validatedon entity 处理器的方法验证,但它没有帮助.

@StreamListener(MediaItemStream.ITEM_LIKED_CHANNEL)
public void handleLikeMessage(@Valid @Payload LikeInputDto like) {...
Run Code Online (Sandbox Code Playgroud)

@Bean
public MethodValidationPostProcessor methodValidationPostProcessor() {
    return new MethodValidationPostProcessor();
}
Run Code Online (Sandbox Code Playgroud)

目前最好的方法是使用自定义服务进行验证,但它看起来并不像想要的那样.

@Log4j2
@Service
@AllArgsConstructor
public class LikeStreamHandler {

    private MediaEventMessagingService mediaEventMessagingService;
    private ValidationService validationService;

    @StreamListener(MediaItemStream.ITEM_LIKED_CHANNEL)
    public void handleLikeMessage(LikeInputDto like) {
        validationService.validate(like);

        log.debug("Handling LIKE message: {}", like);
        mediaEventMessagingService.processLikeEvent(like);
    }
}
Run Code Online (Sandbox Code Playgroud)

java validation spring spring-boot spring-cloud-stream

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

当命令`Brew install python @ 2`时出现错误-`Theme error`。怎么解决?

什么时候 brew install python@2

然后发生错误:

==> make html
Last 15 lines from /Users/oleksandr-yefymov/Library/Logs/Homebrew/python@2/05.make:
writing output... [ 98%] whatsnew/2.1
writing output... [ 98%] whatsnew/2.2
writing output... [ 98%] whatsnew/2.3
writing output... [ 99%] whatsnew/2.4
writing output... [ 99%] whatsnew/2.5
writing output... [ 99%] whatsnew/2.6
writing output... [ 99%] whatsnew/2.7
writing output... [100%] whatsnew/index

generating indices... genindex py-modindex
writing additional pages... download index
Theme error:
An error happened in rendering the page index.
Reason: TemplateNotFound()
make: *** [build] Error 2

READ THIS: …
Run Code Online (Sandbox Code Playgroud)

python macos homebrew

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