java - 找不到名为“myProcessor”的 bean 的类 [net.ab.cd.myProcessor.myProcessor] 嵌套异常是 ClassNotFoundException
问题描述
我正在使用 apache camel 在由处理器接口实现的 MyProcessor 类中发送/接收交换属性:
package net.ab.cd.myProcessor
public class MyProcessor implements Processor {
@Override
void process(Exchange exchange) throws Exception {
//logic to accept and send exchange properties
}
}
我的骆驼 xml 看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
<bean id="myProcessor" class="net.ab.cd.myProcessor.MyProcessor"/>
<camelContext id="mainContext" xmlns="http://camel.apache.org/schema/spring">
<route id="route1">
<from uri="direct:start"/>
<to uri="bean:myProcessor"/>
<to uri="bean:varpop?method=moveToOutboundVariables('statusResponse')"/>
</route>
</camelContext>
我已经构建了我的类项目,以便它使用 shadowJar 重新定位我的包:
group = "net.ab.cd"
shadowJar {
relocate("${project.group}", "${project.group}.myProcessor.shadow") {
exclude "${project.group}.myProcessor.*"
}
}
但最后我收到了这个错误,它无法找到我的类:Cannot find class [net.ab.cd.myProcessor.MyProcessor] for bean with name 'myProcessor' 嵌套异常是 java.lang.ClassNotFoundException