博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mybatis3这个问题我晕为什么对于配置信息的节点放的位置也会报错
阅读量:6757 次
发布时间:2019-06-26

本文共 4619 字,大约阅读时间需要 15 分钟。

今天配置mybatis3时不小心配置成了下面的这样,结果就报一大堆的错误,说是配置文件的问题,我勒个去。我晕。

配置文件的配置信息如下:(其中就是把别名放在了environments节点元素的上面。结果就报这个错误。我晕。

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE configuration
PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
"
>
<configuration>
<typeAliases>
<typeAlias alias="myuser" type="com.action.Users" />
</typeAliases>
<!-- 加载jdbc.properties -->
    <properties resource="jdbc.properties"/>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="${driver}"/>
                <property name="url" value="${url}"/>
                <property name="username" value="${username}"/>
                <property name="password" value="${password}"/>
            </dataSource>
        </environment>
    </environments>
    <!-- 加载映射文件 -->
    <mappers>
        <mapper resource="com/action/User.xml"/>
    </mappers>
</configuration>

错误信息如下:

Exception in thread "main" java.lang.ExceptionInInitializerError

    at com.action.Result.test(Result.java:22)
    at com.action.Result.main(Result.java:14)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:51)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:35)
    at com.action.IBatisSessionFactory.<init>(IBatisSessionFactory.java:18)
    at com.action.IBatisSessionFactory.<clinit>(IBatisSessionFactory.java:13)
    ... 2 more
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:253)
    at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:117)
    at org.apache.ibatis.builder.xml.XMLConfigBuilder.<init>(XMLConfigBuilder.java:57)
    at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:48)
    ... 5 more
Caused by: org.xml.sax.SAXParseException: The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2017)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:901)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
    at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:251)
    ... 8 more

后来就把上面的配置文件中的别名放在了environments节点的下面,调试通过。我晕!我擦!

我勒个去。

真是太没道理了。知道你mybatis3现在框架不错,又是apache的产品。但是你也不能这样做的纠结人啊。我没法说你去。、

 

没天理啊!

转载于:https://www.cnblogs.com/alterhu/archive/2012/06/07/2540976.html

你可能感兴趣的文章
No.2----数据类型(常用的)
查看>>
字符串指针
查看>>
锐捷网关交换机开启dhcp服务
查看>>
android 窃听电话
查看>>
链表例题
查看>>
POJ-1321 棋盘问题 搜索
查看>>
HDU-4478 Where is the King 搜索
查看>>
将博客搬至CSDN
查看>>
大三学长带我学习JAVA。作业1. 第1讲.Java.SE入门、JDK的下载与安装、第一个Java程序、Java程序的编译与执行 大三学长带我学习JAVA。作业1....
查看>>
在ie9浏览器中ajax请求数据始终执行error的问题解决
查看>>
类和原型之工厂模式!
查看>>
hdu 5396 Expression
查看>>
时间选择器(js,css,html)
查看>>
xshell常用命令大全
查看>>
Day01_变量,数据类型_程序交互_流程控制
查看>>
POJ 3087 Shuffle'm Up 模拟,看着不像搜索啊
查看>>
你知道 GNU Binutils 吗?【binutils】
查看>>
OC与swift相互调用
查看>>
quartus ii 中文注释乱码解决办法
查看>>
Linux网卡配置与绑定
查看>>