gpt4 book ai didi

java - Apache Camel : Risk with Bean component not able to link the bean method at compile time

转载 作者:行者123 更新时间:2023-12-01 09:49:47 26 4
gpt4 key购买 nike

Camel 的 bean 组件将方法名称作为字符串,在运行时用于调用该方法。

from("direct:start")
.bean(contactDao, "getContactById")

但是,与 Java 相比,这很糟糕,Java 在编译时本身链接方法,因此在编译时本身会检测到任何错误。

在camel中,bean方法调用的任何错误都不会被捕获,直到在运行时触发该流程。

有什么安全措施可以避免这种情况吗?

最佳答案

使用org.apache.camel.Processor代替bean,或者从您编写Java代码的Processor调用您的bean,并且可以直接调用方法(不是字符串名称)。

关于java - Apache Camel : Risk with Bean component not able to link the bean method at compile time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37672924/

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