我在我的项目中使用Spring MVC和骆驼,但遇到生产者模板不能自动装配的问题。请检查下面的细节,骆驼生产者模板不是在春天注入MVC
文件的web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</context-param>
文件ispatcher-servlet.xml中
<import resource="camel-config.xml"/>
文件骆驼-config.xml中,定义camelContext
<context:component-scan base-package="com.myproject.camel.routes"/>
<camelContext xmlns="http://camel.apache.org/schema/spring" id="myproject.camel">
<contextScan/>
<template id="producerTemplate"/>
</camelContext>
这里是我的JAVA课程:
package com.myproject.connector.camel;
public class CamelConnectorImp{
@Autowired
private ProducerTemplate producerTemplate; //This is null after starting
producerTemplate.requestBodyAndHeaders(serviceEndpoint,request, headers);
...
}
有人能指出我做错了吗?
谢谢佩特,我试过使用@Component,但它没有工作 – Uda