SpringMVC容器管理

2021-10-03 17:48:54 字數 1063 閱讀 9234

負責初始化controller及controlleradvice以外的其他bean

例如:service,dao,datasource,sqlsessionfactorybean等

負責初始化controller及controlleradvice和web層應用到的bean

例如: controller,***等

注意:掃瞄 com.springmvc(可更改) 包下的類的配置

//springmvc配置

base-

package

="com.springmvc" use-

default

-filters=

"false"

>

"annotation" expression=

"org.springframework.stereotype.controller"

/>

"annotation" expression=

"org.springframework.web.bind.annotation.controlleradvice"

/>

<

/context:component-scan>

//spring容器配置

base-

package

="com.springmvc"

>

"annotation" expression=

"org.springframework.stereotype.controller"

/>

"annotation" expression=

"org.springframework.web.bind.annotation.controlleradvice"

/>

<

/context:component-scan>

總結:我們在整合ssm中,兩個容器在掃瞄各自所管理的業務物件。避免出現容器裡有重複的類,導致寫專案報錯!!

博主:點讚的都是帥鍋,美女哦!!!???

spring 容器與 spring mvc 容器

此文幾處有引用別人部落格內容,如有侵權表示歉意!3 spring 容器和spring mvc 容器之間的關係 spring 在整體框架的核心概念中,容器思想是其核心思想。在乙個專案應用中容器的個數可以是多個,spring中可以包含多個容器,其中容器之間存在層級關係。其中spring容器和spring...

spring容器和springmvc容器

springmvc容器是spring容器的子容器,但是子容器可以父容器的bean,但是父容器不能訪問子容器的bean 可以把所有的bean都配置在springmvc容器的配置檔案中,但是拓展性不好。所有一般都各司其職,因此包掃瞄要分開。contextconfiglocationparam name ...

SpringMVC容器和Spring容器

tomcat jetty在啟動時給每個web應用建立乙個全域性的上下文環境,這個上下文就是servletcontext,其為後面的spring容器提供宿主環境。tomcat jetty在啟動過程中觸發容器初始化事件,spring的contextloaderlistener會監聽到這個事件,它的con...