Configuring the Spring container

Before we create controllers for our PWP project, the Spring container must be ready for bean injections and component declarations. First, our Spring MVC container must be annotation-driven so that we can utilize the annotation stereotypes used by the current Spring Framework specification in configuring containers.

To enable the use of annotations inside classes, the following tag must be appearing in the pwp-servlet.xml:

    <mvc:annotation-driven /> 

Second, when the <annotation-driven> tag is enabled, the container must automatically scan all component classes that are part of the Spring MVC web project. This will be enabled through inserting the following tag into the pwp-servlet.xml.

 <context:component-scan base-package="org.packt.personal.web.portal" ...

Get Spring MVC Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.