Search code examples
javaspringspring-mvcspring-annotations

Spring Injection with annotation


How to perform Spring Injection with and <context:component-scan base-package="x.y.z.controller" /> <mvc:annotation-driven/>?

when we use <mvc:annotation-driven/> then we do not have to specify our bean for controller so how to give ref when we use <context:component-scan base-package="x.y.z.controller" />.


Solution

  • use

    @Autowire annotation and define the <\bean> in the Application context.xml

    Here is an example. Take a look