启动springboot报错@Mapper类中存在名称相同的方法重载报错
报错信息:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoController': Unsatisfied dependency expressed through field 'stasticService'; nested exception
·
报错信息:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoController': Unsatisfied dependency expressed through field 'stasticService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stasticServiceImpl': Unsatisfied dependency expressed through field 'stasticMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stasticMapper' defined in file [E:\jq\grid-governance-service\build\classes\java\main\com\jiuqi\governance\grid\dao\mapper\StasticMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.jiuqi.governance.grid.dao.mapper.StasticMapper.getList. please check com/jiuqi/governance/grid/dao/mapper/StasticMapper.java (best guess) and com/jiuqi/governance/grid/dao/mapper/StasticMapper.java (best guess)
截图信息:
1、在启动springboot项目过程中突然报了个错,按照错误信息查找原因,各种的原因都有。但是并没有解决。突然发现看到了在@Mapper类中有两个名称相同的方法,重载。于是按照这个情况查找了一下。找到了原因:在使用@Select等注解的情况下,方法名即为mapper的id,id相同。重载的方法会报这个错。(博主是一点、一点的把代码添加进去。笑哭!!才找到了是哪段代码出现问题)
2、解决办法,将其中一个方法名称进行修改。项目可以正常启动。
总结:不能只会注解的使用,要把注解的原理弄明白,这次就吃了这么的亏,不说了 看@Mapper是怎么实现的去了。
更多推荐
已为社区贡献2条内容
所有评论(0)