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-lib包一直失败,依赖是这样的。

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

看了网上的一些答案说是加入jdk15,因为这个包就是jdk15的。

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

修改成这样就可以了。
还有一种情况就是,引入了同样类型的包,例如

先引入了这个alibb的fastjson包
import com.alibaba.fastjson.JSONObject;

未完待续。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值