问题描述
在Service层调用Mapper层的方法时出错
2023-06-30 15:22:42.730 INFO 1524 --- [ main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2023-06-30 15:22:43.178 INFO 1524 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited
2023-06-30 15:22:43.558 ERROR 1524 --- [ main] c.b.m.core.MybatisConfiguration : mapper[cn.te.pmsstock.mapper.CommodityMapper.getStandardById] is ignored, because it exists, maybe from xml file
原因分析:
错误显示getStandardById方法在mapper层已经错在,但mapper层只有一个
最后发现mapper对应的xml文件中写了两个一样的代码,导致重复使用了getStandardById
解决方案:
步骤一:查看你写的mapper层方法的名字是否写重了。
步骤二:如果你的sql语句是写在xml文件中的,那么查看一下语句中引入的id的名字是不是写重复了。