Context depended on scan component filter

My SpringMVC-based web server typically uses 2 contexts: the webapplication context for the MVC dispatcher servlet and the context of the parent / root application.

<!-- the context for the dispatcher servlet -->
<servlet>
    <servlet-name>webApp</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
....
<!-- the context for the root/parent application context -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:root-context.xml</param-value>
</context-param>

In these contexts, I use component scanning to load all the beans. My packages are named according to their usecase (e.g. com.abc.registration, com.abc.login, etc.), and not based on the technological level (e.g. com.abc.dao, com.abc.services and etc.).

: , - , . MVC- - ( dao/repositorie) ?

<!-- servlet-context.xml -->
<context:component-scan base-package="com.abc.myapp" use-default-filters="false">
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

<!-- root-context.xml -->
<context:component-scan base-package="de.efinia.webapp">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

?

+5
2

:

  • , . web , . .

  • , . , , ( ).

beans ( beans) . , , . singleton, . , , .

, <mvc:annotation-driven/>.

+2

. .

, , , , .

+1

All Articles