Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExce

91 篇文章 17 订阅
26 篇文章 8 订阅

mybatis和spring整合 出现如下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl':
 Injection of resource dependencies failed; 
 nested exception is org.springframework.beans.factory.BeanCreationException:
 Error creating bean with name 'userMapper' defined in file [D:\Program Files\java\workspaces\IdeaWorkspace\WebChat\target\WebChat\WEB-INF\classes\com\lindasoft\mapper\UserMapper.class]:
 Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory';
 nested exception is org.springframework.beans.factory.BeanCreationException: 
 Error creating bean with name 'sqlSessionFactory' defined in URL [file:/D:/Program%20Files/java/workspaces/IdeaWorkspace/WebChat/target/WebChat/WEB-INF/classes/spring/applicationContext.xml]: 
 Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException</span>


 没有其他详细的错误提示,感觉配置也没啥问题。卡住了好长时间,

 网上有提示spring 和mybatis版本可能不配

于是查询一下mybatis-spring的maven库,依赖的包的版本。

http://mvnrepository.com/artifact/org.mybatis/mybatis-spring/1.3.0

于是 看到mybatis-spring版本1.3.0和 mybatis   3.4.0 以及spring  4.2.5.RELEASE版本搭配

    <!-- mybatis -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.0</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.0</version>
    </dependency>

最后修改为这几个版本,正常启动! done!

类似问题都可以按照这个思路来解决。

如果觉得本文对你有帮助,欢迎点赞评论,欢迎关注我,我将努力创作更多更好的文章。

Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.lang.Class.getMethod(Class.java:2227) at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:201) at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$3.run(Injector.java:197) at java.base/java.security.AccessController.doPrivileged(AccessController.java:569) ... 90 common frames omitted 2023-06-11 18:55:14.017 WARN 15576 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'resourceServerConfigurerAdapter': Unsatisfied dependency expressed through field 'pigAccessDeniedHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pigAccessDeniedHandler' defined in com.pig4cloud.pig.common.security.component.PigResourceServerAutoConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.pig4cloud.pig.common.security.component.PigAccessDeniedHandler]: Factory method 'pigAccessDeniedHandler' threw exception; nested exception is java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null
06-12
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明明如月学长

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值