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

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

  • 报错信息
  • 跟源码后发现是实体加载失败时才会报这个错
  • 后面各种试探,各种百度
  • 解决方法: 把classpath:去掉就好了

报错信息

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

你可能感兴趣的:(java,mybatisplus)