Spring vs Spring-mvc component scan


GitHub: https://github.com/SylkeWay/synthful

Note the deliberate difference between non-mvc from mvc classes in this project, in their respective package namespaces:
  • com.synthful.angst.app.durian
  • com.synthful.angst.mvc.durian

This intention would become apparent by looking at the non-mvc and mvc configuration files respectively.
  • run-time classpath: /spring/app-context.xml
    project path: /durian/src/main/resources/spring/app-context.xml
  • run-time classpath: /springweb/mvc-context.xml
    project path: /durian/src/main/resources/springweb/mvc-context.xml

Due to the use of Spring annotation, these bootstrap classes would each need to perform a scan of the classpath to discover the annotated components (aka beans).

The respective component scan instructions:
  • <context:component-scan base-package="com.synthful.angst.app.durian" />
  • <context:component-scan base-package="com.synthful.angst.mvc.durian" />
Their base-package namespaces and their respective descendant paths should not intersect or share any commonality. Otherwise, component singletons due to any common or shared classes between these two namespaces would be instantiated twice.

Note that the components scanned by each bootstrap is pooled together, so that the pool of components is injectable anywhere across the project.

No comments:

Post a Comment