練習1歸納:
這是暫時給我自己看的,暫時不分享項目,如果你遇到了類似的問題,希望對你有所幫助
springmvc中applicationContext.xml和springmvc.xml的掃描的不同
applicationContext.xml要用exclude(排除)
springmvc.xml要用include(包含)
首先,修改applicationContext.xml,將其合到一起
然後,將applicationContext-*.xml路徑改爲applicationContext.xml
需要將config中的所有配置文件手動放到src下
最後修改這幾個配置文件,並修改web.xml和applicationContext.xml以及springmvc.xml
(刪掉了 配置Controller掃描)中,classpath:中的路徑,將多餘的包路徑刪掉
添加的東西
applicationContext.xml
<context:component-scan base-package="cn.cetc.crm">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
springmvc.xml
<context:component-scan base-package="cn.cetc.crm">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
這裏是原項目結構
這裏是新項目結構