posts - 8,  comments - 0,  trackbacks - 0
          一、spring-context*.xml 合并到 spring-mvc.xml 的方法
              spring-servlet.xml 中加入 <import resource="ApplicationContext.xml" />
              ApplicationContext.xml 中把其它的xml文件import進來
              web.xml 
              SpringMVC核心分發器 加入參數 <param-value>classpath:spring-mvc.xml</param-value>
              不加載    <param-value>classpath*:/spring-context*.xml</param-value>
              controller/service等都在mvc中加載
               <context:component-scan base-package="com.mweb.**.controller" />
              <context:component-scan base-package="com.mweb.**.service" />。。。。需要加載的@Component等
              加入:
               <aop:aspectj-autoproxy proxy-target-class="true" />

          二、spring-context*.xml / spring-mvc.xml 分開加載掃描的方法 
          web.xml 中:
           <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/spring-context*.xml</param-value>
           </context-param>
           <listener> 
                  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    必須加入才行
           </listener>

           <servlet>
            <servlet-name>spring</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>classpath:spring-mvc.xml</param-value>
                  </init-param>
            <load-on-startup>1</load-on-startup>
           </servlet>

          spring-mvc.xml 中:

           <context:component-scan base-package="com.mweb.**.controller" />   掃描 controller

           <aop:aspectj-autoproxy />         aop 參考下面的也行

          1. <aop:aspectj-autoproxy proxy-target-class="true">  
          2.         <aop:include name="controllerAspect"/>     @Aspect聲明的類  
          3.     </aop:aspectj-autoproxy> 


           

          spring-context.xml中:
               <context:component-scan base-package="com.mweb.**.extension,
                           com.mweb.**.service,
                           com.mweb.base.aspect,
                           com.mweb.base.shiro.realm" />
           <aop:aspectj-autoproxy proxy-target-class="true" />
          這樣就可以了





          posted on 2016-11-22 09:44 liufx 閱讀(3277) 評論(0)  編輯  收藏 所屬分類: 調試錯誤記錄
          <2016年11月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 安平县| 台北市| 合江县| 丹东市| 阳谷县| 无为县| 阿克苏市| 泸水县| 盐山县| 青岛市| 渝中区| 汽车| 榆社县| 清远市| 来宾市| 阳春市| 西峡县| 西华县| 射阳县| 乌鲁木齐市| 安塞县| 龙山县| 泰安市| 河津市| 广汉市| 富裕县| 泗洪县| 灵川县| 石景山区| 商洛市| 怀来县| 武宣县| 府谷县| 河东区| 宝山区| 扎鲁特旗| 西华县| 南召县| 宜兰市| 敦煌市| 法库县|