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); }