I am using simple annotations to create a component (@Component) that autowires in the MessageTemplate.
Assuming the template is defined as follows:
and the simple component class isCode:<bean id="messageTemplate" name="messageTemplate" class="org.springframework.flex.messaging.MessageTemplate" > <property name="messageBroker" ref="_messageBroker" /> </bean>
The reference for messageTemplate will not autowire as expected; an exception is thrown stating:Code:package web.flex; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.flex.messaging.MessageTemplate; @Component public class EventPublisher { @Autowired private MessageTemplate messageTemplate; }
Code:org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.flex.messaging.MessageTemplate wmscache.web.flex.EventPublisher.messageTemplate; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.flex.messaging.MessageTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


Reply With Quote