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

电玩女神 2022-05-31 02:42 277阅读 0赞

错误:

  1. 二月 05, 2018 10:38:35 上午 org.apache.catalina.core.StandardContext listenerStart
  2. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  3. 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
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
  6. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
  7. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  10. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:736)
  11. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
  12. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
  13. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
  14. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
  15. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
  16. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811)
  17. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251)
  18. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
  19. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
  20. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
  21. at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  22. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  23. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  24. at java.lang.Thread.run(Thread.java:748)
  25. 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
  26. at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:481)
  27. at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
  28. at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
  29. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1523)
  30. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1482)
  31. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222)
  32. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
  33. ... 20 more
  34. 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
  35. at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:140)
  36. at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:449)
  37. at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:422)
  38. at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:195)
  39. at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:461)
  40. ... 26 more

原因:

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

SouthEast

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

SouthEast 1

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

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

发表评论

表情:
评论列表 (有 0 条评论,277人围观)

还没有评论,来说两句吧...

相关阅读