当前位置: 首页 > news >正文

Could not resolve resource location pattern错误解决方案

为什么80%的码农都做不了架构师?>>>   hot3.png

此类问题还有mapperLocations类型出错等问题,sqlSessionFactory bean无法加载等.具体错误简化如下:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [D:\git responsitory\panda\target\classes\org\panda\dao\UserMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [org/panda/mapping/*.xml]: ServletContext resource [/org/panda/mapping/] cannot be resolved to URL because it does not exist

 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [org/panda/mapping/*.xml]: ServletContext resource [/org/panda/mapping/] cannot be resolved to URL because it does not exist

 

Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'org.springframework.core.io.Resource[]' for property 'mapperLocations'; nested exception is java.lang.IllegalArgumentException: Could not resolve resource location pattern [org/panda/mapping/*.xml]: ServletContext resource [/org/panda/mapping/] cannot be resolved to URL because it does not exist

 

Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [org/panda/mapping/*.xml]: ServletContext resource [/org/panda/mapping/] cannot be resolved to URL because it does not exist

 

最后一条错误信息是关键,就是启动tomcat的时候无法找到xml文件,在确保你的所有配置文件均没有问题的情况下,检查一下target文件夹下面是否包含了mapping的xml文件.

报错前:

153520_wpLH_2481244.png

说明xml文件没有被maven打包到target下面.在pom.xml的<build>标签中加入:

<resources>
   <resource>
    <directory>src/main/java</directory>
    <includes>
       <include>**/*.xml</include>
    </includes>
    <filtering>true</filtering>
   </resource>
</resources>

这样,重新 clean package tomcat:run,你就会发现如下:

153749_ozwB_2481244.png

 

总结:maven在编译和打包文件时会将xml文件漏掉,有的ide不会,但是我的idea会,所以在pom.xml中加入以上代码,便可解决问题!

转载于:https://my.oschina.net/qkmc/blog/1524266

相关文章:

  • PAT乙级-1026. 程序运行时间(15)
  • HTTP中GET与POST的区别 99%的错误认识
  • 好汉两个半第十二季/全集Two and a Half Men迅雷下载
  • Learning How to Learn
  • 一起玩树莓派3+使用Gitlab搭建专业Git服务
  • Android Finalizing a Cursor that has not been deactivated or closed
  • 土耳其重大数据泄露事件 数据库安全受关注
  • 互联网分析师:5G距离我们还有多远?
  • oracle增加sequence
  • 藏在高端智能手机芯片里的“外交官”:射频前端
  • 哈尔滨工业大学校园网运营:开放兼容,灵活认证
  • js 获取中文的拼音
  • Wi-Fi新标准HaLow正面挑战ZigBee、Z-Wave
  • 物联网发展的六大智能化前景
  • 《嫌疑人X的献身》——两个天才之间的思想火花
  • ES6指北【2】—— 箭头函数
  • 《Java编程思想》读书笔记-对象导论
  • 【划重点】MySQL技术内幕:InnoDB存储引擎
  • 【跃迁之路】【735天】程序员高效学习方法论探索系列(实验阶段492-2019.2.25)...
  • Android优雅地处理按钮重复点击
  • echarts的各种常用效果展示
  • Java 最常见的 200+ 面试题:面试必备
  • js操作时间(持续更新)
  • Markdown 语法简单说明
  • MySQL-事务管理(基础)
  • React-redux的原理以及使用
  • SpringBoot 实战 (三) | 配置文件详解
  • 安卓应用性能调试和优化经验分享
  • 彻底搞懂浏览器Event-loop
  • 两列自适应布局方案整理
  • 深入浅出webpack学习(1)--核心概念
  • 数据科学 第 3 章 11 字符串处理
  • 详解NodeJs流之一
  • 小程序上传图片到七牛云(支持多张上传,预览,删除)
  • 协程
  • 一道闭包题引发的思考
  • 用 Swift 编写面向协议的视图
  • 栈实现走出迷宫(C++)
  • - 转 Ext2.0 form使用实例
  • ionic异常记录
  • ​520就是要宠粉,你的心头书我买单
  • ​一些不规范的GTID使用场景
  • #FPGA(基础知识)
  • #NOIP 2014# day.2 T2 寻找道路
  • #我与Java虚拟机的故事#连载10: 如何在阿里、腾讯、百度、及字节跳动等公司面试中脱颖而出...
  • (bean配置类的注解开发)学习Spring的第十三天
  • (day 2)JavaScript学习笔记(基础之变量、常量和注释)
  • (delphi11最新学习资料) Object Pascal 学习笔记---第5章第5节(delphi中的指针)
  • (二)学习JVM —— 垃圾回收机制
  • (十三)Java springcloud B2B2C o2o多用户商城 springcloud架构 - SSO单点登录之OAuth2.0 根据token获取用户信息(4)...
  • (心得)获取一个数二进制序列中所有的偶数位和奇数位, 分别输出二进制序列。
  • (原)记一次CentOS7 磁盘空间大小异常的解决过程
  • (原創) 如何將struct塞進vector? (C/C++) (STL)
  • (转)IIS6 ASP 0251超过响应缓冲区限制错误的解决方法
  • 、写入Shellcode到注册表上线