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的。

未完待續。。。。

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