Could not resolve resource location pattern [classpath:com.zjht.goodspeakerapph5/mapper/*.xml]

原创 2018年02月05日 11:16:40

错误:

二月 05, 2018 10:38:35 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.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 [classpath:com.zjht.goodspeakerapph5/mapper/*.xml]: class path resource [com.zjht.goodspeakerapph5/mapper/] cannot be resolved to URL because it does not exist
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
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 [classpath:com.zjht.goodspeakerapph5/mapper/*.xml]: class path resource [com.zjht.goodspeakerapph5/mapper/] cannot be resolved to URL because it does not exist
	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:481)
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
	at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1523)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1482)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	... 20 more
Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com.zjht.goodspeakerapph5/mapper/*.xml]: class path resource [com.zjht.goodspeakerapph5/mapper/] cannot be resolved to URL because it does not exist
	at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:140)
	at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:449)
	at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:422)
	at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:195)
	at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461)
	... 26 more

原因:

    com.zjht.goodspeakerapph5/mapper/*.xml在我的项目是这样的

即使com.zjht.goodspeakerapph5看起来是一个一级目录,实际上是一个三级的目录,即是:


路径应改为com/zjht/goodspeakerapph5/mapper/*.xml, 即:

<property name="mapperLocations" value="classpath:com/zjht/goodspeakerapph5/mapper/*.xml"></property>


版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_30938705/article/details/79258017

XML编程

在现代的开发之中,XML技术无处不在,在各个开发框架中,也都到处充斥着XML配置文件的身影。本课程将为读者讲解XML的产生背景,并且详细分析了HTML与XML的区别、XML核心语法,重点在于XML的解析技术(DOM、SAX、DOM4J工具),同时讲解了如何在HTML页面利用JavaScript进行DOM解析实现页面动态开发。官方QQ群:612148723。
  • 2016年12月31日 23:18

maven整合ssm打war部署项目启动启动报错 Could not resolve resource location pattern

tomcat运行war报错IllegalArgumentException: Could not resolve resource location pattern [classpath :com/w...
  • wwrzyy
  • wwrzyy
  • 2018-03-31 00:53:47
  • 49

记一次mybatis的classpath踩坑记录

spring + mybatis配置路径错误引起的错误
  • jinzhencs
  • jinzhencs
  • 2016-01-27 17:02:57
  • 13583

报错:classpath resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist

参考: http://www.jianshu.com/p/800fe918cc7a ssm整合的时候报错:Caused by: java.lang.IllegalArgumentException:...
  • qinkang1993
  • qinkang1993
  • 2017-02-27 00:35:36
  • 7653

关于Spring加载classpath与classpath*的过程剖析

本篇文章是由朋友的一篇博客引出的,博客原文地址:http://jinnianshilongnian.iteye.com/blog/1416322     他这篇博客比较细的讲解了classpath与c...
  • Truong
  • Truong
  • 2014-05-25 21:03:47
  • 5477

mybatis错误:Could not resolve resource location pattern [classpath:com/demon/user/mapper/*.xml]: class

ssm框架下mybatis报错:Could not resolve resource location pattern [classpath:com/demon/user/mapper/*.xml]:...
  • Youyou_0826
  • Youyou_0826
  • 2018-03-21 15:17:11
  • 54

Spring mvc 4.0+freemarker抛javax.servlet.ServletException: Could not resolve view with name

Spring 4.0+Spring mvc4.0+Freemarker集成项目,一切的东西都配好了,但是出现javax.servlet.ServletException: Could not reso...
  • abc360200314
  • abc360200314
  • 2014-04-03 13:00:43
  • 12330

maven无法对src/main/java下面的xml文件进行编译的解决办法

报错原因: 使用maven进行打包发布项目时,maven无法对src/main/java下面的xml文件进行编译打包 目录结构:此项目的mapper包下的BankLogMapper.xml无...
  • m0_37893932
  • m0_37893932
  • 2017-07-10 15:49:00
  • 686

idea 创建的maven+spring+mybatis项目整合 报错无法创建bean

最近在做一个由maven构建的spring+mybatis+struts2项目,刚开始的时候是用自己的老电脑Win7环境下的eclipse写的,托管到了码云上面,刚开始什么问题都没有 直到某一天在公...
  • kep159
  • kep159
  • 2016-07-26 20:29:47
  • 6236

org.apache.ibatis.type.TypeException: Could not resolve type alias异常

2014-04-25 10:57:23 [ERROR] [org.springframework.web.context.ContextLoader.initWebApplicationContext...
  • yangjun19890825
  • yangjun19890825
  • 2014-04-25 12:45:42
  • 42598
收藏助手
不良信息举报
您举报文章:Could not resolve resource location pattern [classpath:com.zjht.goodspeakerapph5/mapper/*.xml]
举报原因:
原因补充:

(最多只允许输入30个字)