springboot mybatis切换到mybatis plus时报错 :java.lang.IllegalArgumentException: name

报错信息

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [com/baomidou/mybatisplus/autocon
figure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instanti
ate [org.apache.ibatis.session.SqlSessionFactory]: Factory method ‘sqlSessionFactory’ threw exception; nested exception is java.lang.IllegalArgumentException: name

跟源码后发现是实体加载失败时才会报这个错

Caused by: java.lang.IllegalArgumentException: name
at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:703) ~[na:1.8.0_201]
at sun.misc.URLClassPath$1.next(URLClassPath.java:277) ~[na:1.8.0_201]
at sun.misc.URLClassPath$1.hasMoreElements(URLClassPath.java:287) ~[na:1.8.0_201]
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:604) ~[na:1.8.0_201]
at java.net.URLClassLoader$3$1.run(URLClassLoader.java:602) ~[na:1.8.0_201]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_201]
at java.net.URLClassLoader$3.next(URLClassLoader.java:601) ~[na:1.8.0_201]
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:626) ~[na:1.8.0_201]

后面各种试探,各种百度

发现有些mybatisplus版本typeAliasesPackage不能写:classpath:,如我现在用的

com.baomidou
mybatis-plus-boot-starter
3.0.6

mybatis-plus:
mapper-locations: classpath:mapper/*.xml
typeAliasesPackage: classpath: com.zyh.mall.product.model.po

解决方法: 把classpath:去掉就好了

mybatis-plus:
mapper-locations: classpath:mapper/*.xml
typeAliasesPackage: com.zyh.mall.product.model.po

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值