我在我的項目中使用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