大半夜 找一个bug 总算解决了
运行环境: eclipse Version: Mars.1 Release (4.5.1) (自带maven)
问题 : org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): yycg.base.dao.mapper.userMapper.selectUser
已经测试spring注入是没有问题的
原因:也就是 配置文件没有在找到。
解决过程:
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ project ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\Users\Administrator\workspace\yycgproject\target\classes
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) < compile @project <<<
C:\Users\Administrator\workspace\yycgproject\target\classes 在这里是项目部署的位置
发现mapper 目录 没有xml配置文件(火大)
解决办法:
在pom里面加上一下代码(注意这是在 <build> 里面添加的)
<resources>
<!-- 如果不添加此节点mybatis的映射配置文件都会被漏掉。 -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<!-- 将项目中的resources目录下的配置文件拷贝到taget目录下 如果不添加此节点resources目录下的配置文件都会被漏掉。-->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>