一、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 参考下面的也行
- <aop:aspectj-autoproxy proxy-target-class="true">
- <aop:include name="controllerAspect"/> @Aspect声明的类
- </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 阅读(3267)
评论(0) 编辑 收藏 所属分类:
调试错误记录