Camel-K does not recognize local package(Camel-K 不识别本地包)
问题描述
我有一个使用自己的处理器的 RouteBuilder 类.使用 Maven 在 Camel 中本地运行时,它运行良好.但是,当我尝试使用 camel-k 时,它说找不到包.我有什么需要做的吗?
I have a RouteBuilder class that is using its own Processor. When running locally in Camel using Maven, it runs fine. However, when I try to use camel-k, it says it cannot find the package. Is there something I need to do?
我的处理器
package com.test.processor;
import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.component.file.GenericFile;
public class MyProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
Message inMsg = exchange.getIn();
Object body = inMsg.getBody();
if (body instanceof File) {
System.out.println("Is a FILE");
} else {
System.out.println("Not a FILE");
}
if (body instanceof GenericFile) {
System.out.println("Is a GF for sure");
GenericFile gf = (GenericFile) body;
String fileName = gf.getFileName();
System.out.println("Filename: " + fileName);
} else {
System.out.println("NOT a GF");
}
}
}
路由器
package com.javainuse.route;
import org.apache.camel.builder.RouteBuilder;
import com.test.processor.MyProcessor;
public class SimpleRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
// Transfer files from one another using a processor
from("file:C:/inputFolder?noop=true")
.process(new MyProcessor())
.to("file:C:/outputFolder")
.setBody().simple("Test")
.log("Test log");
}
}
我正在使用 minikube
并运行命令:kamel 运行 SimpleRouteBuilder.java --dev
I am using minikube
and run the command:
kamel run SimpleRouteBuilder.java --dev
[1] Exception in thread "main" org.apache.camel.RuntimeCamelException: org.joor.ReflectException: Compilation error: /com/test/route/SimpleRouteBuilder.java:4: error: package com.test.processor does not exist
[1] import com.test.processor.MyProcessor;
推荐答案
这是意料之中的,因为 camel-k 不知道在哪里可以找到您的处理器的类,所以您有两个选择:
This is expected as camel-k does not know where to find the classes for your processor so you have two options:
- 将处理器嵌入到路由的内部类中
- 将您的处理器打包为 maven 工件(您也可以使用 jitpack 以避免在测试时将其发布到 maven 存储库)并将其列为任何其他依赖项
这篇关于Camel-K 不识别本地包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Camel-K 不识别本地包
基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01