Little confused, the basic spring mvc app has this:
app-config.xml
<context:component-scan base-package="org.springframework.samples.mvc.basic" />
and the mvc-config.xml has:
<!-- Configures the @Controller programming model -->
<mvc:annotation-driven />
-
Do you really need both?
-
for component-scan, does this mean if I don’t put the correct package path my @Controller and @Service markers will have no effect?
If I need more than one package, do I just duplicate the entry?
I tried using just the mvc:annotation-driven but that didn’t work, I had to put com.example.web.controllers in the component-scan xml node to make it work.
context:component-scan is clear
So @Controller is just a Spring bean. Nothing else.
And
mvc:annotation-driven
Which is similar to
If I need more than one package, do I just duplicate the entry?
You can if you want. context:component-scan is just a bean post-processor.
Or