欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mybatis+atomikos出现invalid bound statement (not found)

程序员文章站 2022-05-23 12:26:17
...

我在用atomikos做分布式事务的时候出现invalid bound statement (not found),网上找了好多办法都没有解决,最后我还是通过谷歌查找到解决办法。

解决办法如下:

在配置SqlSessionFactory的方法中添加你项目编译后Class包mapper的路径:如下代码中的:sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:com/byr/myselfdemo/mapper/mysql_mapper/mapper_xml/*.xml"));

public SqlSessionFactory systemSqlSessionFactory() throws Exception {
   	SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
   	sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().
   			getResources("classpath*:com/byr/myselfdemo/mapper/mysql_mapper/mapper_xml/*.xml"));
   	sqlSessionFactoryBean.setDataSource(systemDataSource());
   	return sqlSessionFactoryBean.getObject();
   }