spring3.0.5+mybatis3.0.4 出现Mapped Statements collection already contains value

   我用spring3.0.5+mybatis3.0.4 +Struts2搭建的框架,在通过DAO调用MyBatis的Mapper时出现

java.lang.IllegalArgumentException: Mapped Statements collection already contains value for xxx.xxx.dao.method

   

    网上找了个把小时,没发现有好的解决方案,大概都说mybatis并发错误,前台多个请求并发请求mapper

原因大概是请求时mybaits解析sql并执行导致的并发错误。通过在mybaits初始化时加上以下这句可以解决。
    sqlSesssionTemplate.getConfiguration().buildAllStatement。

    由于我用的是注解,上面语句是在手工实例化时可以,想起可以用@Scope("prototype")来,在DAO类上加上此注解,问题解决!

猜你喜欢

转载自anreddy.iteye.com/blog/1993497
今日推荐