1 回答

TA貢獻1839條經(jīng)驗 獲得超15個贊
1.在springmvc配置文件中掃描bean的時候。只掃描包含@controller。因為既然要和spring整合,那么springmvc還是專心做web請求的轉(zhuǎn)發(fā)吧。
2.在spring配置文件中去掉@controller的掃描。其他bean都是單例的,在容器啟動的時候,一起初始花了。
最后,其實單獨使用 springmvc也是可以的。讓他管理所有bean.
1 在主容器中(applicationContext.xml),將Controller的注解打消掉
[html] view
plaincopy
<context:component-scan base-package="com">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
2 而在springMVC配置文件中將Service注解給去掉
[html] view
plaincopy
<context:component-scan base-package="com">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
- 1 回答
- 0 關(guān)注
- 654 瀏覽
添加回答
舉報