2 fnzf14428547 fnzf14428547 于 2016.03.07 10:53 提问

spring-mybatis.xml配置出错了,请大神看看

这是第一个错

org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.fishoad.services.QuartzService] for bean with name 'quartzTask' defined in class path resource [spring-quartz.xml]; nested exception is java.lang.ClassNotFoundException: com.fishoad.services.QuartzService
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)
Caused by: java.lang.ClassNotFoundException: com.fishoad.services.QuartzService
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
`



三月 07, 2016 10:49:24 上午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: 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 [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 [classpath:/com/fishoad/dao/*.xml]: class path resource [com/fishoad/dao/] 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:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)

第二个错

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/fishoad/dao/*.xml]: class path resource [com/fishoad/dao/] cannot be resolved to URL because it does not exist
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:479)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:511)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:505)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1461)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1197)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 21 more
Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:/com/fishoad/dao/*.xml]: class path resource [com/fishoad/dao/] 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:430)
at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:403)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
... 27 more


8个回答

qq_24848969
qq_24848969   2016.05.02 00:37

在pom.xml 下面的build便签下加上


src/main/resources

/*.properties
/*.xml
**/*.tld

false

rui888
rui888   Ds   Rxr 2016.03.07 11:00

class path resource [com/fishoad/dao/] cannot be resolved to URL because it does not exist
提升路径不存在啊。

fnzf14428547
fnzf14428547 在的啊
接近 2 年之前 回复
rui888
rui888   Ds   Rxr 2016.03.07 11:27

对了你第一个错误 com.fishoad.services.QuartzService 这个也没有。

rui888
rui888 回复fnzf14428547: 你这个QuartzService 是定时任务用到的吗?现在没有找到,你先去掉看看,不清楚为什么
接近 2 年之前 回复
fnzf14428547
fnzf14428547 可是我也有啊,是不是他没找到我的文件啊,这些都有啊,文件错了也不报错,我不知道什么情况
接近 2 年之前 回复
wojiushiwo945you
wojiushiwo945you   Ds   Rxr 2016.03.07 12:53

配置文件路径修正下:classpath:/com/fishoad/dao/*.xml去掉第一个斜杠试试。

wojiushiwo945you
wojiushiwo945you 回复fnzf14428547: 那你把项目clean下,重新编译项目试试。
接近 2 年之前 回复
fnzf14428547
fnzf14428547 好像是classes文件下都没有编译这些文件
接近 2 年之前 回复
qq_24848969
qq_24848969   2016.05.02 00:39
Hreo111
Hreo111   2017.08.20 03:59

在POM.XML文件追加

  <resources>  
    <!--编译之后包含xml-->  
    <resource>  
      <directory>src/main/java</directory>  
      <includes>  
        <include>**/*.xml</include>  
      </includes>  
      <filtering>true</filtering>  
    </resource>  
  </resources>  

Hreo111
Hreo111   2017.08.20 04:00

更新一下

    <resources>
        <!--编译之后包含xml-->
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
            <filtering>true</filtering>
        </resource>
    </resources>

</build>
Hreo111
Hreo111   2017.08.20 04:00
<build>
    <resources>
        <!--编译之后包含xml-->
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
            <filtering>true</filtering>
        </resource>
    </resources>

</build>
Csdn user default icon
上传中...
上传图片
插入图片