ssm框架错误总结

1.当出现以下错误:
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/mapping/*Mapper.xml]: class path resource [com/mapping/] cannot be resolved to URL because it does not exist

错误原因:这是出现了,没有扫描导bean,com/mapping这个源没有扫描到。

一开始我是写成这样的

  <!-- 自动扫描mapping.xml文件 -->
        <property name="mapperLocations" value="classpath:com/mapping/*Mapper.xml"></property>

因为是看网上搭建框架的步骤一步步来的,很多复制黏贴,所以有些错误无法自己找出。

这里如果无法扫描到,请修改成这样。

  <!-- 自动扫描mapping.xml文件 -->
        <property name="mapperLocations" value="classpath*:com/mapping/*Mapper.xml"></property>

加个星号就行了。。。

2.用maven添加net.sf.json的jar包无法添加。

错误原因:

<dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
    <classifier>jdk15</classifier>
</dependency>

少添加了一个jdk15,因为这个包是jdk15的。

未完待续。。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章