我正在从 Java 8 升级到 Java 11。即使之前使用的 Spring 版本也是 4.x,现在我已经升级到 Spring 5.x
我正在使用骆驼作为路线
我的骆驼上下文文件如下
<bean id="samplePriceBean"
class="com.abc.SamplePriceBean">
<constructor-arg index="0"
ref="route1" />
<constructor-arg index="1"
ref="route2" />
<constructor-arg index="2"
ref="myCamelContext" />
<constructor-arg index="3" value="route1" />
<constructor-arg index="4" value="route1" />
</bean>
<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route id="listRoute" autoStartup="false">
<from
uri="file:{{abc.list}}?noop=true&" />
<to uri="direct:route1"
id="route1" />
</route>
<route id="readRoute" autoStartup="false">
<from
uri="file:{{abc.read}}?noop=true&" />
<to uri="direct:route2"
id="route2" />
</route>
</camelContext>
现在,当我在控制台中运行应用程序错误时,如下所示
Error creating bean with name 'samplePriceBean' defined in class path resource [app-camel.xml]: Cannot resolve reference to bean 'route1' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'route1' available
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:787)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:226)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1358)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1204)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
应用程序无法解析骆驼上下文中定义的路由
我正在使用 JDK 11、SPring 5.x、Apache camel 3.0.0