SpringMVC+Mybatis架构中的问题记录

本文记录了一个关于Spring配置切面找不到特定实现类的问题及其解决过程。问题出现在使用特定的execution表达式时,导致SpringMVC扫描到了Service的bean,而Spring自身扫描时忽略这些bean,最终影响到事务管理。文中还提到了Spring3.X项目在不同JDK版本间的编译问题及MySQL配置注意事项。

2014/08/16 记录

今天遇到个问题。折腾了我大约4个小时,好坑啊由于之前没遇到过

我的包是这么分的:com.project名.模块名.service.impl     在spring 配置这个切面 execution(* com.project名..*Impl.*(..)) 他 就是找不到com.project名.模块名.service.impl以下的*Impl类

而且此配置就算配错了,他不报错,而且当我同一时候用junit測试,同一时候载入三个配置文件 springMVC.xml spring.xml spring-mybatis.xml 它有正常,一旦通过web初始化就出问题,假设web同一时候载入三个文件也不会出问题。当他这样配置时仅仅会在日志文件里记录例如以下:

DEBUG - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@15872f5] was not registered for synchronization because synchronization is not active
DEBUG - Fetching JDBC Connection from DataSource
DEBUG - JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@152f43b] will not be managed by Spring
DEBUG - ooo Using Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@152f43b]
DEBUG - ==>  Preparing: select * from test where testid=?

 
DEBUG - ==> Parameters: 1(Integer)
DEBUG - <==      Total: 1
DEBUG - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@15872f5]
DEBUG - Returning JDBC Connection to DataSource

这里显示的是Spring没有去管理数据库的事务。后来发现问题,是SpringMVC扫描的时候载入了Service的bean,在Spring在扫描的时候就不再将Service扫描进去。从而Spring在配置事物的时候失效。

所以在配置文件中,将SpringMVC 要配置仅仅扫秒带controller注解的类。


2015/10/20 Spring 3.X的项目在jdk 1.7 编译之后在jdk1.8 下用不了,报context初始化异常。另外mysql配置文件中不能有表达式,应该直接写数值比方max_allowed_packet=2*1024*1024 这样是错误的。

要max_allowed_packet=2097152

转载于:https://www.cnblogs.com/zsychanpin/p/7193791.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值