我有一个驼峰应用程序,它不承认的路线。它是一个spring引导应用程序。
这是spring引导应用程序类
我已经在yaml文件中定义了所有属性。但当应用程序启动时,会显示0个路由。你知道为什么它会显示出来吗。
我的pom.xml有以下条目。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.dsfsdaf.orchestration</groupId>
<artifactId>orchen-con-service</artifactId>
<version>1.0-RELEASE</version>
<name>OrchServi</name>
<description>Orch</description>
<properties>
<java.version>11</java.version>
<camel.version>3.1.0</camel.version>
<jackson.version>1.9.13</jackson.version>
<kafka.version>2.6.0</kafka.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- <version>2.2.6.RELEASE</version>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<!-- <version>2.2.6.RELEASE</version>-->
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-kafka-starter</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<!-- <version>${kafka.version}</version>-->
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>3.1.0</version>
<!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<!-- <version>2.10.0</version>-->
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-jaeger-cloud-starter</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
<!-- This dependency is for WebClient implementation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>jolt-core</artifactId>
<version>0.0.17</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>json-utils</artifactId>
<version>0.0.10</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
camel上下文文件如下:这是camel路由文件
<beans xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-
spring.xsd"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans">
<bean id="routeIRIntake" class="com.adsfdsaf.orch.camel.transformer.TransClass"/>
<!-- Camel routes for orch module -->
<camelContext xmlns="http://camel.apache.org/schema/spring" id="camel">
<route id="orch">
<from id="cdi-log" uri="{{kafka-uri-base}}{{kafkaProp}}" />
<process ref="routeIRIntake" />
<log id="cdi-payload-clq" message="somemsg" />
<setHeader headerName="{{orch.camel.header.http.name}}">
<constant>{{orch.http.method.post}}</constant>
</setHeader>
<setHeader headerName="{{orch.http.header.content-type}}">
<simple>{{orch.http.header.app-json}}</simple>
</setHeader>
<setHeader headerName="{{orch.http.header.accept}}">
<simple>{{orch.http.header.app-json}}</simple>
</setHeader>
<log id="pld-to-sch" message="Routing to schval" />
<to uri="{{orch.sch-val.uri}}" />
<choice>
<when>
<simple>${header.CamelHttpResponseCode} == ${status.success} </simple>
<log id="schema-val-success" message="message for success" />
<to uri="{{kafka-inb-intake}}{{kafkaProp}}" />
</when>
<otherwise>
<log id="schema-validation-failed" message="failed message " />
</otherwise>
</choice>
</route>
<route id="intnotif">
<from id="intnotif-log" uri="{{kafka-outbound}}{{kafkaProp}}" />
<log id="log-notif" message="Received resp" />
<setHeader headerName="{{orch.camel.header.http.name}}">
<constant>{{orch.http.method.post}}</constant>
</setHeader>
<setHeader headerName="{{orch.http.header.content-type}}">
<simple>{{orch.http.header.app-json}}</simple>
</setHeader>
<setHeader headerName="{{orch.http.header.accept}}">
<simple>{{orch.http.header.app-json}}</simple>
</setHeader>
<to uri="{{notif.serv.uri}}" />
<choice>
<when>
<simple>${header.CamelHttpResponseCode} == ${status.success} </simple>
<log id="notification-success" message="success message" />
</when>
<otherwise>
<log id="notification-failed" message="failed message" />
</otherwise>
</choice>
</route>
</camelContext>
</beans>
1条答案
按热度按时间dhxwm5r41#
我猜你错过了
@ImportResource
主要应用程序类上的sb注解。假设你有一个camel-context.xml
文件位于src/main/resources
,应该是这样的:这里有一个完整的例子。