用的是 SSM3的框架 Spring MVC 3.1 + Spring 3.1 + Mybatis3.1

第一种情况
Spring MVC 和 Spring 整合的时候,SpringMVC的springmvc.xml文件中 配置扫描包,不要包含 service的注解,Spring的applicationContext.xml文件中
配置扫描包时,不要包含controller的注解,如下所示:
SpringMVC的xml配置:
<context:component-scan base-package="com.insigma">

  <context:exclude-filter
type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>

启动时的配置文件,包含组件扫描、映射以及设置参数,让不扫描带有注解的类。为什么要这样设置?因为与不是同时加载,如果不进行这样的设置,那么,spring@ServiceapplicationContext.xmlServicecglibServiceapplicationContext 中的事务配置不起作用,发生异常时,无法对数据进行回滚。以上就是原因所在。
同样的在Spring的xml配置如下:
<context:component-scan
base-package="com.insigma">           
 <context:exclude-filter
type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
@Controllerspringmvc.xml

注意以上几点就OK了。

这是转载文章...........

最新文章

  1. iOS创建安全的单例
  2. LR手动关联新手总结
  3. Yii2的邮件配置
  4. 瘟疫公司中国版(Android)手动破解内购
  5. Java多线程编程核心技术---对象及变量的并发访问(二)
  6. JAVA敏捷开发环境搭建
  7. 我存在,你深深的循环里--从反射看JSON死循环
  8. 【转】https,https的本地测试环境搭建,asp.net结合https的代码实现,http网站转换成https网站之后遇到的问题
  9. java后台正则验证
  10. MySQL中char、varchar和text的区别
  11. WebApi2官网学习记录---Media Formatters
  12. GDKOI2016 游记
  13. Using variables inside Postman and Collection Runner
  14. 解析JavaScript中的sort()排序方法以及原理
  15. 禁止root登陆sshd/并修改默认端口号
  16. [agc016B][Colorful Hats]
  17. Android百大框架排行榜
  18. 【ASP.NET】Layout使用详解
  19. NOIP2018游记(更新完毕)
  20. 理解mvn命令

热门文章

  1. yum search/intall, Error: xz compression not available
  2. 如何重启mysql服务
  3. arm linux 下移植busybox 的tftp
  4. resize2fs: Bad magic number in super-block while trying to open /dev/centos/root Couldn&#39;t find valid filesystem superblock
  5. Spring Boot发布和调用RESTful web service
  6. java中Swing编程再度练习篇
  7. Linux打包下载命令
  8. 1 ignite核心特性
  9. IOCP编程原理(转)
  10. 用原生JS和html5进行视频截图并保存到本地