Mapped Statements collection does not contain value for真正的解决办法
来源:互联网 发布:淘宝哪家香水是假货 编辑:程序博客网 时间:2024/06/06 18:12
http://blog.csdn.net/wang623145708/article/details/27213685
http://www.cnblogs.com/oyx305/p/5340683.html
idea,maven,spring-mybatis
这问题搞了我一下午,差点精神崩溃
一开始报这种错,当然想到百度,于是乎基本上全是http://blog.csdn.net/wang623145708/article/details/27213685这种答案,然后就仔仔细细地对了一遍,发现没毛病啊,,FFFFFFFFFFFFFFFFuck,
接着,我就找了是不是我sqlID写错了,是不是sqlSessionTemplate没注入,是不是mapper.xml的resultMap少了什么属性,然后各种搜索姿势,发现他丫的都不是啊,这时已经下午3点了(从12点20开始搞的),然后想起中午拿的外卖还没吃,肚子饿得不行,然后就吃了个外卖,看了些视频,就3点50左右,玩了几把飞车,丫的大号居然说我开挂封我一个月,就只有玩小号,放松下头脑,好吧,问题还是要解决的,不能视而不见,没办法,我再次点开了IDEA,
我把下午的解决姿势回想了一遍,到底是哪的错呢?有的说是xml没放进classPath,也就是没有mark as resources,嗯,试了几遍没什么用,最后,我把这个异常的英文拿去百度翻译了下,“映射语句集合不包含它的值”,要么,mapper.xml中确实没有我敲的sqlId,要么就是没有找到mapper.xml,排除第一种可能,然后又想,是怎样的原因导致没有找到mapper.xml,按刚才说的mark as resources是打进了target中的,但是idea却表示没有,然后又看了下扫描mapper.xml配置的路径,嗯 ,这是个问题,虽然mark as resources是把xml打包在了target中,但是位置变了啊,sssssshit,然后百度了下maven打包mapper.xml时的问题,哈,出来了
一般情况下,我们用到的资源文件(各种xml,properites,xsd文件等)都放在src/main/resources下面,利用maven打包时,maven能把这些资源文件打包到相应的jar或者war里。
有时候,比如mybatis的mapper.xml文件,我们习惯把它和Mapper.java放一起,都在src/main/java下面,这样利用maven打包时,就需要修改pom.xml文件,来把mapper.xml文件一起打包进jar或者war里了,否则,这些文件不会被打包的。(maven认为src/main/java只是java的源代码路径)。
总之,我最后添了这几行代码
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
至于上述几行代码的意思,希望各位自己去百度哈,我就不多说了
在重启服务器后,也就是maven重新打包后,发现target中,mapper.xml还是放在原目录中,在没加这几句代码的时候,是没有mapper这个目录的,(我是把mapper.xml放在mapper目录(包)中的),然后直到写完这篇文章已经17:08咯,我只想说,今下午我到底做了啥
- Mapped Statements collection does not contain value for真正的解决办法
- Mapped Statements collection does not contain value for RelateMarketingMapper....解决办法
- Mapped Statements collection does not contain value for的解决方法
- batis 错误 Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for...
- mybatis错误 Mapped Statements collection does not contain value for
- mybatis错误 Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for *
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for Addressbook.pageSelect
- Mapped Statements collection does not contain value for Addressbook.getByIds
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for
- Mapped Statements collection does not contain value for
- 【C语言】之链表操作
- [NOIP2017模拟]Xor
- [DP] ZROI 2017提高1 T2.给 Ca
- sqli-labs学习记录(四)
- C++ 实现Mutex(底层用win32) 和 C++中析构过程 和常量性的大坑
- Mapped Statements collection does not contain value for真正的解决办法
- 运算符(23)加密可以这样简单(位运算)
- Error:This Gradle plugin requires Studio 3.0 minimum
- RxJava2.0学习笔记(简介,线程控制,常见操作符)
- bzoj 2760: [JLOI2011]小A的烦恼
- 10.6西南联训爆0总结
- LeetCode Week4
- Codeforces868F Yet Another Minimization Problem -- 决策单调性优化DP
- 组合数问题 解题报告