mybatis配置中,用package代替typeAlias,为什么会报这个错?

严重: 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 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in file [D:\tomcat\apache-tomcat-7.0.57\webapps\questionnaire\WEB-INF\classes\config\spring-common.xml]: 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 file [D:\tomcat\apache-tomcat-7.0.57\webapps\questionnaire\WEB-INF\classes\config\spring-common.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [config/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 'Xzl'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Xzl

clipboard.png
用typeAlias一行一行的写就没问题,用package代替就有问题?

阅读 7.1k
5 个回答

低级错误.

你包名叫model, 而你定义别名时所写的包名叫mode.

谢邀,mybatis配置文件好像没有package这个标签,typealias是配置简单类名,不知道你想用package代替什么。

看起来没有错
你可以在看一下这个文档看看有没有什么疏漏 或 包扫描是否开启之类的

clipboard.png
起别名是这么起的
dz.aaa.ssm.po是实体类的包名称,这样的话你就不用在mybaits的配置文件加那个别名设置了
默认别名为 首字母大写。

是不是你写错了单词?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题