0

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" />.

Paulius Matulionis
  • 23,085
  • 22
  • 103
  • 143
Mayur Patel
  • 155
  • 1
  • 1
  • 10

2 Answers2

1

use

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

Here is an example. Take a look

codeMan
  • 5,730
  • 3
  • 27
  • 51
0

You can use the JSR 330 annotations: @Inject. You can also use the Spring specific @Autowired, but @Inject is better since based on a standard reference. See the Spring documentation for more information.

Example from the Spring documentation:

@Inject
public void setMovieFinder(MovieFinder movieFinder) {
    this.movieFinder = movieFinder;
}
LaurentG
  • 11,128
  • 9
  • 51
  • 66