You are doing something wrong. @Qualifier as well as <qualifier>
are for injecting dependencies of beans. But you are not injecting anything into your bean and not injecting your bean anywhere, you are just trying to define the bean.
In your case it is important to understand that in xml you are defining beans which will be instantiated at runtime. And at runtime generic types are erasured: type erasure
That said it doesn't matter what generic types/hints you can possibly give to Spring it will be completely useless as at runtime - when the spring will instantiate the beans - all generic types information will be lost.
The correct usage of qualifier tag would be if you had:
public class MovieRecommender {
@Autowired
@Qualifier("main")
private MovieCatalog movieCatalog;
// ...
}
and xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<bean class="example.SimpleMovieCatalog">
<qualifier value="main"/>
<!-- inject any dependencies required by this bean -->
</bean>
<bean id="movieRecommender" class="example.MovieRecommender"/>
</beans>
For a fallback match, the bean name is considered a default qualifier value.
You can read more at the spring docs