- 浏览: 4403 次
- 性别:
- 来自: 桂林
最新评论
Spring 3 and MyBatis 3.0.4 / 3.0.6: MalformedParameterizedTypeException
- 博客分类:
- java
根据网络的资料通过maven构建了一个Spring+MyBatis项目,其中pom.xml文件中引入mybatis和Spring架包:
<!-- spring webmvc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.0.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.0.6.RELEASE</version> </dependency> <!-- spring-mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.0.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.0.4</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.14</version> </dependency>
结果运行后报错如下:
2012-04-01 15:51:29.842::WARN: Failed startup of context org.mortbay.jetty.plugin.Jetty6PluginWebAppContext@170a650{/haiping,E:\MyEclipse9MWorkSpaces\haiping\src\main\webapp} org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:540) at org.mortbay.jetty.servlet.Context.startContext(Context.java:135) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:110) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132) at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:371) at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:307) at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:203) at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157) at org.apache.maven.cli.MavenCli.main(MavenCli.java:121) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: java.lang.reflect.MalformedParameterizedTypeException at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42) at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35) at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77) at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31) at sun.reflect.generics.visitor.Reifier.visitArrayTypeSignature(Reifier.java:141) at sun.reflect.generics.tree.ArrayTypeSignature.accept(ArrayTypeSignature.java:24) at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:76) at java.lang.reflect.Method.getGenericParameterTypes(Method.java:282) at org.springframework.core.GenericTypeResolver.getTargetType(GenericTypeResolver.java:65) at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:80) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodParameter(GenericTypeAwarePropertyDescriptor.java:147) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.isExcludedFromDependencyCheck(AbstractAutowireCapableBeanFactory.java:1234) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1069) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) ... 47 more 2012-04-01 15:51:29.846::WARN: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/spring/root-context.xml]: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException: java.lang.reflect.MalformedParameterizedTypeException at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42) at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35) at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77) at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86) at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122) at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31) at sun.reflect.generics.visitor.Reifier.visitArrayTypeSignature(Reifier.java:141) at sun.reflect.generics.tree.ArrayTypeSignature.accept(ArrayTypeSignature.java:24) at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:76) at java.lang.reflect.Method.getGenericParameterTypes(Method.java:282) at org.springframework.core.GenericTypeResolver.getTargetType(GenericTypeResolver.java:65) at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:80) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodParameter(GenericTypeAwarePropertyDescriptor.java:147) at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:129) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.isExcludedFromDependencyCheck(AbstractAutowireCapableBeanFactory.java:1234) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1211) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1069) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:282) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:204) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:540) at org.mortbay.jetty.servlet.Context.startContext(Context.java:135) at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:510) at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:110) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) at org.mortbay.jetty.Server.doStart(Server.java:222) at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132) at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:371) at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:307) at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:203) at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157) at org.apache.maven.cli.MavenCli.main(MavenCli.java:121) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) 2012-04-01 15:51:29.872::INFO: Started SelectChannelConnector@0.0.0.0:8080 [INFO] Started Jetty Server
困恼啊 一遍一遍查看代码 都无发现重大错误 后在国外的老外的一片文章中找到了和我出现一样问题
看后顿然醒悟,原来自己”二二“地搞错了版本,解决方案,把mybatis的版本从3.0.4改成更高一点版本3.0.6便可:
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.0.6</version> </dependency>
总结:问题不是很严重,只怪自己太小白,因为问题太简单了,别人都没出现这种”二“不能在“二”的低级错误,故写这篇文章来取消自己一下!
相关推荐
spring整合mybatis。/13spring4_mybatis2/lib/aopalliance.jar /13spring4_mybatis2/lib/asm-3.3.1.jar /13spring4_mybatis2/lib/aspectjweaver.jar /13spring4_mybatis2/lib/cglib-2.2.2.jar /13spring4_...
Spring 3.0.5版本是一个稳定且功能强大的依赖注入(DI)和面向切面编程(AOP)框架,而MyBatis 3.0.4则是一个灵活的SQL映射框架,简化了数据库操作。将两者整合,可以实现松耦合的持久层设计,提高代码的可维护性和...
### Spring MVC 3.0.5 + Spring 3.0.5 + MyBatis3.0.4 全注解实例详解 #### 概述 本文档旨在通过一个实际的例子来详细阐述如何利用Spring MVC 3.0.5、Spring 3.0.5以及MyBatis3.0.4三个技术栈实现全注解式的Web应用...
总结,本实例详细介绍了如何使用 Spring MVC 3.0.5、Spring 3.0.5 和 MyBatis 3.0.4 进行全注解开发,涵盖了开发环境配置、Maven 的使用、SSM 整合以及如何在 Eclipse 和 MyEclipse 中集成 Maven。这个教程对于希望...
Struts2、Spring3.0和Mybatis3.0.4是Java开发中常见的三大框架,它们各自在应用程序的不同层面提供了强大的支持。本实例将详细讲解如何在这三个框架基础上实现一个邮件发送功能,同时支持附件上传。对于Java开发者来...
基于spring4.0+版本,包括spring4.2.0 ,mybatis3.4.1,spring-webmvc-4.2.0,log4j,commons-logging-1.2,commons-logging-1.2等全部的jar包
在本教程中,我们将深入探讨如何使用Spring、Spring MVC 3.0.5以及MyBatis 3.0.4这三个流行的Java框架构建一个全注解的Web应用程序。这个实例详解将帮助开发者理解如何有效地集成这三个组件,实现高效的数据访问和...
spring boot整合mybatis web项目,代码非常整洁干净,无多余代码,内含一张表的读取操作,及建表语句,非常适合初学者。解压后用IntelliJ IDEA打开,然后导入表user_t,修改下数据库连接的配置,改成自己本机的,即可...
后端使用Spring Boot和MyBatis作为开发框架,而前端使用Vue和ElementUI作为开发工具。 后端开发框架 后端使用Spring Boot作为开发框架,Spring Boot是一个轻量级的框架,易于学习和使用,可以快速搭建项目。它提供...
标题中的“spring 3.0.4 +hibernate3.6+mybatis3.0.4+struts 2.1.8+freemarker整合”提到了一个经典的Java Web开发框架组合,这个组合在早期非常流行,用于构建企业级应用。下面将详细介绍这些技术及其整合方式。 1...
Spring3.0.6 +mybatis 3.0.6配置文档
标题 "spring3和mybatis3的初始探索" 涉及到的是两个非常重要的Java开发框架——Spring和MyBatis的集成与应用。Spring是一个全面的后端开发框架,提供了依赖注入、AOP(面向切面编程)、MVC(模型-视图-控制器)等...
在3.0.4版本中,MyBatis提供了一系列关键功能,帮助开发者更高效地处理数据库操作。以下是对`mybatis-3.0.4源码`的详细解析。 一、核心组件 1. SQLSessionFactory:这是MyBatis的核心组件,负责创建SQLSession对象...
spring+spring mvc+mybatis+bootstrap+jquery+html+springboot+thymeleaf http://localhost:8080/index 前台地址:http://localhost:8080/user/login 账号张三 密码11111 后台地址:...
在Java开发领域,Spring、SpringMVC和MyBatis是三个非常重要的框架,它们共同构建了一个强大而灵活的Web应用程序栈。Spring作为一个全面的后端开发框架,提供了依赖注入(DI)和面向切面编程(AOP)等功能,极大地...
11. **MyBatis-Spring 集成**:如果项目使用了 Spring,可以集成 MyBatis-Spring,它提供了自动配置、事务管理等功能,简化了在 Spring 中使用 MyBatis 的过程。 这些知识点涵盖了 MyBatis 的主要功能和使用方式,...