In the spring mvc project, I want to insert @Controller into another bean, something like this:
@Controller public class MyController { .. } @Component public class SomeSpringBean { @Resource private MyController myController; .. }
This does not work, although the @Controller annotation is a specialization of @Component, such as @Service (which works):
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com..Mycontroller] is defined
I also tried to get a bean from ApplicationContext directly.
I would like to avoid any discussion about why I want to introduce controllers, and that I should rather create an extra layer of abstraction and introduce it instead :)
java spring spring-mvc dependency-injection
Wojciech gรณrski
source share