Feb 16 2009

Spring annotations based config

Published by Gilles at 9:41 pm under J2EE, Java, Spring

Application context

In your web/WEB-INF folder, create a new applicationContext.xml file. That file will contain the configuration.

XML:
  1. <xml version="1.0" encoding="UTF-8"/>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/-beans-2.5.xsd
  7. http://www.springframework.org/schema/context
  8. http://www.springframework.org/schema/context/-context-2.5.xsd">
  9.  
  10. <!-- Let us use annotation driven beans -->
  11.     <context:annotation-config/>
  12.  
  13. <!-- Classpath components scanning -->
  14. <context:component-scan base-package="PACKAGE_TO_BE_SCANNED"/>
  15.  
  16. </beans>

  • The <context:annotation-config /> element is used to automatically register all of 's standard post-processors for annotation-based configuration.
  • The <context:component-scan annotation> element is used to enable autodetection of the stereotyped classes in the scanned package.

Pages: 1 2 3 4 5

Trackback URI | Comments RSS

Leave a Reply