posts - 8,  comments - 0,  trackbacks - 0
          一、spring-context*.xml 合并到 spring-mvc.xml 的方法
              spring-servlet.xml 中加入 <import resource="ApplicationContext.xml" />
              ApplicationContext.xml 中把其它的xml文件import進(jìn)來
              web.xml 
              SpringMVC核心分發(fā)器 加入?yún)?shù) <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)  編輯  收藏 所屬分類: 調(diào)試錯誤記錄
          <2016年11月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          留言簿

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 时尚| 永川市| 布尔津县| 内黄县| 铜山县| 贵德县| 兴安县| 澄江县| 马边| 吕梁市| 三河市| 五河县| 烟台市| 万年县| 潮州市| 临武县| 恩施市| 南召县| 旌德县| 朝阳县| 麻阳| 桂东县| 高青县| 右玉县| 新和县| 萍乡市| 东乡族自治县| 游戏| 诏安县| 青川县| 长海县| 宝兴县| 柳河县| 宜阳县| 台南市| 昌邑市| 永德县| 庄河市| 娱乐| 金坛市| 依兰县|