1、Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cd.mapper.UserMapper.insert
问题分析:这是在ssm项目整合时(mybatis部分)所遇到的错误,异常的意思是找不到一个对应的statement去处理这个方法(即xml配置文件中没有对应的处理方法)配置文件没有什么问题,因为是在idea下使用maven管理项目的,而使用maven管理项目的时候,在生成目标文件(target)时,默认是不编译xml配置文件的(这里离通过检查target目标文件中有无对应的xml文件可以验证)。(因此我习惯将配置文件放在WEB-INF下),可是我这个是使用逆向工程生成的mapper接口其对应的xml配置文件,所以这个sql配置文件是在classpath路径下的。
解决方法:在工程的pom文件中设置目标文件生成所需要的xml文件,配置如下:
<build>
<!--设置maven生成的目标文件编译以下路径的源文件-->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
上述问题问题解决之后,又出现了一个问题,因为我是使用逆向工程生成的mapper接口和mapper.xml配置文件,因此在项目部署的时候可能会出现以下问题:
2、java.lang.IllegalArgumentException: Result Maps collection already contains value for cd.mapper.UserMapper.BaseResultMap
这个问题时说我的mapper.xml配置文件中BaseResultMap的id重复,这时,我们需要删除一个即可。