Announcement Announcement Module

JavaConfig forum decommissioned in favor of Core Container

As described at

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at
See more
See less
JavaConfig for <context:component-scan> Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaConfig for <context:component-scan>

    So far I have this tag in my XML config file:
    <context:component-scan base-package="de.hska"/>

    I'm doing most of the configuration via JavaConfig in Spring 3.0. Therefore, I'd like to get rid of the component-scan in XML and do it via JavaConfig. Any hint is appreciated!

    My web application uses JSF 2 for the presentation layer, and in web.xml I have the following section.
    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    <listener-class>org.springframework.web.context.request.Requ estContextListener</listener-class>

  • #2
    You may use AnnotationConfigWebApplicationContext for this purpose.

    Set a "contextClass" init-param with param-value of ConfigWebApplicationContext.

    The value of "contextConfigLocation" may be fully-qualified @Configuration class names and/or fully-qualified base packages to scan.

    See for a more complete example.