2 baidu 31167667 baidu_31167667 于 2016.04.28 23:29 提问

eclipse下 springmvc 和 mybatis整合 ,配置文件不知道哪里错了,不会改

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [springmvc.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:380)
at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:295)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 21 more
Caused by: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:106)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parse(XMLConfigBuilder.java:89)
at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:374)
... 24 more
Caused by: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:317)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:104)
... 26 more
Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:100)
at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:63)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:128)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:121)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:111)
... 29 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:114)
at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:127)
at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:98)
... 33 more
Caused by: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
at org.apache.ibatis.io.Resources.classForName(Resources.java:254)
at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:110)
... 35 more

四月 28, 2016 11:07:14 下午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [springmvc.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.entity.User'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.entity.User
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1486)
at org.springframework.bea

3个回答

baidu_31167667
baidu_31167667   2016.04.28 23:30

springmvc.xml





<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
   <property name="dataSource" ref="dataSource"></property>
   <property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>
<bean id="userDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="com.dao.UserDao"></property>
    <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
</bean>
<bean id="userService" class="com.service.impl.UserServiceImpl">
    <property name="userDao" ref="userDao"></property>
</bean>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
</bean>

<context:component-scan base-package="com.web"/>
<mvc:annotation-driven/>
baidu_31167667
baidu_31167667   2016.04.28 23:31

web.xml


Springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springmvc.xml



Springmvc
/


encodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
utf-8


encodingFilter
/*


org.springframework.web.context.ContextLoaderListener


contextConfigLocation
classpath:springmvc.xml

jhfsdfs
jhfsdfs   2016.04.29 09:24

mybatis里面的user依赖,全类名写错了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Spring+SpringMVC +MyBatis整合配置文件案例
Spring+SpringMVC +MyBatis整合配置文件解析
Spring+SpringMVC+MyBatis整合配置文件的搭建
SSM项目的环境搭建: 一、项目的目录结构如下: 二、导入的jar包:WEB-INF/lib下 三、resources下的几个配置文件+WEB-INF下的web.xml文件需要自己配置: wei.xml: pmis characterEncoding org.springframework.web.fi
spring、springmvc、mybatis整合文件配置详解
首先非常感谢原文作者Pickle,读完原作者这篇博客受益良多,所以拿来自己记录下。 原文地址是:http://www.cnblogs.com/wxisme/p/4924561.html 官方文档地址: Spring:http://spring.io/docs MyBatis:http://mybatis.github.io/mybatis-3/ (1)web.xml文件的配置
springmybatisspringmvc整合配置文件
放在src项目根目录 如图: 代码如下: spring和mybatis整合:applicationContext-mybatis.xml     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:context="http://www.springframework.org/sc
eclipse 使用maven 集成spring+springMVC+mybatis
使用SSM(spring、SpringMVC和Mybatis)已经有三个多月了,项目在技术上已经没有什么难点了,基于现有的技术就可以实现想要的功能,当然肯定有很多可以改进的地方。之前没有记录SSM整合的过程,这次刚刚好基于自己的一个小项目重新搭建了一次,而且比项目搭建的要更好一些。以前解决问题的过程和方法并没有及时记录,以后在自己的小项目中遇到我再整理分享一下。这次,先说说三大框架整合过程。个人认
spring,springmvc,mybatis基本整合(一)--xml文件配置方式(1)
这个整合,只是最基本的整合,并且是xml配置文件的方式之一,即其中的mybatis是采用非mapper接口的方式。(第二遍采用mapper接口方式;第三遍采用注解的方式;第四篇采用注解基于maven的方式),记录在这里,以免下次忘记时留作备用。一,整体结构 二,所需jar包: 实质上并不需要全部导入,这里为了方便就全部导入啦。 (1)spring4全部jar包 (2)mybatis全
spring + springmvc +mybatis 搭建 maven 项目的核心配置文件
首先我们来简单看看我们的目录结构 那么我们简单说下这个项目:这是我们做过的电商项目所以名字为ddbuy src/main/java :编写主要代码 core:为核心代码,只要分为 1.pageModel:分页模型,所有实体类的基类 package com.weshop.core.dao.page; import java.util.ArrayList; import jav
【SpringMVC+mybatis】7.mybatis SqlMapConfig.xml文件详解
mybatis的全局配置文件SqlMapConfig.xml主要配置内容有:properties(属性),settings(全局配置参数),typeAliases(类型别名),typeHandlers(类型处理器),objectFactory(对象工厂),plugins(插件),environments(环境集合属性对象),environment(环境子属性对象),transactionManag
springmvc + spring + mybatis + maven整合配置文件
springmvc + spring + mybatis + maven整合配置文件
maven+springMVC+mybatis+junit详细搭建过程整合实现demo,带有jar包和测试类。增删改查的操作供大家学习
本文中的完整代码已经上传到CSDN:http://download.csdn.net/detail/qq_5101437/9240859 摘要 在做javaweb的过程中,搭建框架式比较头疼事情了,每次重新去搭建太浪费时间了,现在把框架搭建完成,可以在以后的项目中运用,节约开发成本。 maven springMVC mybatis log4j javaweb项目框架搭建