开发者社区> 问答> 正文

Mybatis_PageHelper采用spring方式集成报错?报错

@Liuzh_533 你好,想跟你请教个问题:

使用spring方式集成,web功能启动的时候报错,错误信息如下:

2014-12-27 21:13:51 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined in file [D:\workplace\yhgo\.metadata\.me_tcat\webapps\yhzy\WEB-INF\classes\spring-jdbc.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:\workplace\yhgo\.metadata\.me_tcat\webapps\yhzy\WEB-INF\classes\spring-jdbc.xml]: Cannot create inner bean 'com.github.pagehelper.PageHelper#725857cc' of type [com.github.pagehelper.PageHelper] while setting bean property 'plugins' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.PageHelper#725857cc' defined in file [D:\workplace\yhgo\.metadata\.me_tcat\webapps\yhzy\WEB-INF\classes\spring-jdbc.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'properties' threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/ibatis/scripting/xmltags/SqlNode
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)



配置方式如下:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
   <property name="dataSource" ref="dataSource"/>
<property name="mapperLocations">
<list>
  <value>classpath:com/base/dao/mapper/*Mapper.xml</value>
  <value>classpath:com/xuelang/yhzy/dao/mapper/*Mapper.xml</value>
</list>
</property>
<property name="typeAliasesPackage" value="com.xuelang.yhzy.domain"/>
<!-- 分页插件设置 -->
<property name="plugins">
   <array>
     <bean class="com.github.pagehelper.PageHelper">
       <property name="properties">
         <value>
           dialect=mysql
           reasonable=true
           pageSizeZero=true
         </value>
       </property>
     </bean>
   </array>
</property>
</bean>

展开
收起
爱吃鱼的程序员 2020-06-14 18:41:09 535 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    你用的Spring版本是什么?看着好像不支持这种写法的properties

    2020-06-14 18:41:25
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
集成智能接入网关APP:优化企业级移动办公网络 立即下载
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载
云效助力企业集成安全到DevOps中 立即下载

相关实验场景

更多