내 프로젝트에서 Spring MVC와 Camel을 사용하고 있지만 producerTemplate을 Autowired 할 수 없다는 문제가 발생했습니다. 아래에 세부 사항을 확인하시기 바랍니다Camel producerTemplate이 스프링 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);
...
}
누군가 내가 잘못하고있는 것을 지적 할 수 있습니까?
감사합니다. Petter, @Component를 사용해 보았지만 작동하지 않았습니다. – Uda