mybatis逆向工程后得到的文件,使用idea映射mapper,程序运行时报错org.apache.ibatis.binding.BindingException:
具体错误:
Servlet.service() for servlet [ego-manager-web] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.bjsxt.ego.rpc.mapper.TbItemMapper.selectByExample
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.bjsxt.ego.rpc.mapper.TbItemMapper.selectByExample
使用idea工具,将mybatis逆向工程生成的pojo和mapper映射拷贝到工程中,运行中包绑定异常,
问题1:idea中不能自动将mapper中的Java文件和xml文件打包到一起
解决:在工程的pom文件中加入资源映射配置
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
问题2:
install后发现java与xml依然没有映射在一起,可能是resources目录下的目录结构出现问题
解决:将resources下的目录重新创建,一级一级的创建,然后重新install。
至此问题解决,重新打包后的目录结构: