zoukankan      html  css  js  c++  java
  • 使用PlaceHolder,测试碰见的问题

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [E:JavawebWorkSpace aotao-manger aotao-manger-web argetclassesspringapplicationContext-dao.xml]: Invocation of init method failed; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 12; 元素类型为 "plugins" 的内容必须匹配 "(plugin)+"。

    和视频上面的一起写的,但是最后我的报错!!!  明明都一模一样!

    最后解决的稀里糊涂的,就是在SqlMapconfig.xml文件中的配置

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration
            PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
        <!-- 配置分页插件 -->
        <plugins>
            <plugin interceptor="com.github.pagehelper.PageHelper">
                <!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->        
                <property name="dialect" value="mysql"/>
            </plugin>
        </plugins>
    </configuration>

    下面是测试类中的代码

        @Test
        public void testPageHelper()
        {    //创建一个spring容器
            ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:spring/applicationContext-*.xml");
            //从spring容器中获得Mapper的代理对象
            TbItemMapper mapper = applicationContext.getBean(TbItemMapper.class);
            //执行查询,并分页
            TbItemExample example = new TbItemExample();
            //分页处理
            PageHelper.startPage(2, 10);
            List<TbItem> list = mapper.selectByExample(example);
            //取商品列表
            for (TbItem tbItem : list) {
                System.out.println(tbItem.getTitle());
            }
            //取分页信息
            PageInfo<TbItem> pageInfo = new PageInfo<>(list);
            long total = pageInfo.getTotal();
            System.out.println("共有商品:"+ total);
        }
  • 相关阅读:
    一些关于微电子方面的笔试题
    [JavaScript]Redeclaring variable
    [JavaScript]How to run Jasmine in Intellij/WebStorm?
    [JavaScript] Use `+` opertor to add one string and one number
    [CoffeeScript]CoffeeScript学习笔记
    Study Note for grunt
    grunt.js
    [转]Vim常用命令速查
    如何在Web Page里体验CoffeeScript的 功能
    [JavaScript] 如何使用Ruby gem运行jasmine test case
  • 原文地址:https://www.cnblogs.com/kangxinxin/p/8058423.html
Copyright © 2011-2022 走看看