Autowiring is not working when configured through XML
class ConfigurationDetails {
private @Resource String esHostURL;
private @Resource int maxMessageCounter;
private @Resource String queueName;
// Assume : This class has all getter and setter methods and a default
constructor
}
Another Class
public class SpringMessageListener implements MessageListener {
@Resource ConfigurationDetails configDetails; // With getter and
setter method for this
............
..........
And in my XML
<bean id="aListener" class="com.vzw.es.cosumer.SpringMessageListener"
autowire="byName"/>
<bean id="configDetails" class="com.vzw.es.pojo.ConfigurationDetails"
autowire="byName">
<property name="esHostURL"
value="http://obsgracstg-db0.odc.vzwcorp.com:9200"/>
<property name="maxMessageCounter" value="500"/>
<property name="queueName" value="ES_queue"/>
</bean>
Now the bean with id configDetails is not getting autowired meaning when I
debug the code and see the configDetails in class SpringMessageListerner
it is showing null. But when I explicitly do the
appContext.getBean("configDetails") it gives me the not null Object. Any
idea why the Autowiring is not working here. Am I missing anything here.
Spring Masters appreciate your quick response.
No comments:
Post a Comment