此问题多数由配置错误导致。以下是一个包含路由构建器的示例。确保使用了正确的依赖项。
application.properties:
camel.component.servlet.mapping.context-path=/camel-example
camel.component.servlet.mapping.match-on-uri-prefix=true
camel.component.servlet.servlet-name=camel-servlet
camel.context.name=CAMEL_CONTEXT
camel.springboot.name=CAMEL_SPRINGBOOT_CONTEXT
ExampleRoute.java:
package com.example.camel;
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class ExampleRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("jms:queue:inputQueue")
.log("message: ${body}")
.to("jms:queue:outputQueue");
}
}
pom.xml:
org.springframework.boot
spring-boot-starter-activemq-artemis
org.apache.camel.springboot
camel-spring-boot-starter
${camel-version}
org.apache.camel.springboot
camel-jms-starter
${camel-version}
org.apache.camel.springboot
camel-servlet-starter
${camel-version}