I am trying to create a bean named messageSource. Below is my xml for bean creation.
Code : spring.xml
When I tried to load the application context usingCode:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd> <bean id="messageSource" class="com.MessageSource"> <property name="message" value="${myName}" /> </bean> </beans>
it fails giving following exception.Code:ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
I was able to get the application working by giving different name for messageSource bean (e.g. myMessageSource) .Code:Exception in thread "main" org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'messageSource' must be of type [org.springframework.context.MessageSource], but was actually of type [com.MessageSource]
But why is it throwing this exception ? Is it expected behaviour ?
Regards,
prithvi


Reply With Quote
