I am trying to create a bean named messageSource. Below is my xml for bean creation.

Code : spring.xml
Code:
<?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>
When I tried to load the application context using
Code:
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
it fails giving following exception.
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]
I was able to get the application working by giving different name for messageSource bean (e.g. myMessageSource) .

But why is it throwing this exception ? Is it expected behaviour ?

Regards,
prithvi