qq_22676421
橘子^^
采纳率0%
2015-05-05 09:32

java配置文件出错了不知道是哪求解决

  1. ```
  2. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [I:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\cb\WEB-INF\classes\spring-mvc-applicatonContext-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [I:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\cb\WEB-INF\classes\com\xiao\comment\dao\mapper\CommentMapper.xml]'; nested exception is 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.xiao.comment.bean.Comment'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1488)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:524)
  5. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
  6. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
  7. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
  9. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
  10. at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
  11. at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
  12. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
  13. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
  14. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
  15. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  16. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
  17. at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
  18. at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
  19. at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
  20. at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
  21. at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
  22. at org.apache.catalina.core.StandardService.start(StandardService.java:516)
  23. at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
  24. at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
  25. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  26. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  27. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  28. at java.lang.reflect.Method.invoke(Unknown Source)
  29. at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
  30. at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
  31. Caused by: org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [I:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\cb\WEB-INF\classes\com\xiao\comment\dao\mapper\CommentMapper.xml]'; nested exception is 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.xiao.comment.bean.Comment'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  32. at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:462)
  33. at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:336)
  34. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547)
  35. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
  36. ... 27 more
  37. 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.xiao.comment.bean.Comment'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  38. at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
  39. at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
  40. at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:460)
  41. ... 30 more
  42. Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.xiao.comment.bean.Comment'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  43. at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:100)
  44. at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:257)
  45. at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:244)
  46. at org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:236)
  47. at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:109)
  48. ... 32 more
  49. Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.xiao.comment.bean.Comment'. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  50. at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:114)
  51. at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:127)
  52. at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:98)
  53. ... 36 more
  54. Caused by: java.lang.ClassNotFoundException: Cannot find class: com.xiao.comment.bean.Comment
  55. at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:188)
  56. at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:87)
  57. at org.apache.ibatis.io.Resources.classForName(Resources.java:254)
  58. at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:110)
  59. ... 38 more

    一下配置文件
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
    <mapper namespace="com.xiao.comment.dao.CommentMapper" >
    <resultMap id="BaseResultMap" type="com.xiao.comment.bean.Comment" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue May 05 17:24:12 CST 2015.
    -->
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="userid" property="userid" jdbcType="INTEGER" />
    <result column="pointid" property="pointid" jdbcType="INTEGER" />
    <result column="detail" property="detail" jdbcType="VARCHAR" />
    <result column="addtime" property="addtime" jdbcType="TIMESTAMP" />
    <result column="username" property="username" jdbcType="VARCHAR" />
    <result column="commenttype" property="commenttype" jdbcType="VARCHAR" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="state" property="state" jdbcType="INTEGER" />
    <result column="parentid" property="parentid" jdbcType="INTEGER" />
    <result column="parenttype" property="parenttype" jdbcType="VARCHAR" />
    </resultMap>
    
    mybatis配置
    
    <!-- SqlSesstion Factory 定义 ↓ mybatis文件 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- 自动扫描entity目录,省略Configuration.xml里手工配置 -->
        <property name="mapperLocations" value="classpath*:/com/xiao/**/dao/**/*Mapper.xml"/>
    </bean>
    <!-- SqlSession Factory 定义 ↑ -->
    
    <!-- MapperScannerConfigurer定义,用于扫描Mapper DAO类 ↓ -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.xiao.**.dao.**"/>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
    </bean>
    <!-- MapperScannerConfigurer定义,用于扫描Mapper DAO类 ↑ -->
    
    实体类
    package com.xiao.comment.bean;
    

import java.util.Date;

public class Comment {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column cb_comment.id

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • wang_huanming wang_huanming 6年前

    没有找到这个类com.xiao.comment.bean.Comment

    点赞 评论 复制链接分享
  • xiaoyaxue xiaoyaxue 6年前

    CommentMapper.xml 检查下这个文件有没有什么地方写错,看你异常是提示找不到com.xiao.comment.bean.Comment

    点赞 评论 复制链接分享
  • wangya168 Novice起航 6年前

    mybaties的配置文件有错误!

    点赞 评论 复制链接分享
  • fanst_ fanst_ 6年前

    Cannot find class: com.xiao.comment.bean.Comment

    点赞 评论 复制链接分享
  • qq_22676421 橘子^^ 6年前

    求各位大神关注一下吧!!!!!不明白什么错啊a

    点赞 评论 复制链接分享

为你推荐