• 使用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);
        }
  • 相关阅读:
    普林斯顿宣布开源 25 核处理器
    瑞芯微RK3399宣布系统开源,进入百余种行业市场!
    Qt浅谈之二十App自动重启及关闭子窗口
    学在LINUX下编程(各种情况比较详细)
    ASP.NET开发规范:OWIN
    IDEA14中安装go语言插件
    sqlserver不能直接create table as select
    表复制语句select into from 与 insert into select 区别鉴赏
    实现Asp.net Mvc分布式Session Redis群集
    大小端模式
  • 原文地址:https://www.cnblogs.com/kangxinxin/p/8058423.html
Copyright © 2020-2023  润新知