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


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

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

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

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


src/main/resources

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

false

图片说明](https://img-ask.csdn.net/upload/201605/02/1462120759_183219.png)


在POM.XML文件追加

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

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

</build>

更新一下

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

</build>