• mybatis3这个问题我晕为什么对于配置信息的节点放的位置也会报错


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

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

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration
    PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"
    "
    http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
    <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的产品。但是你也不能这样做的纠结人啊。我没法说你去。、

    没天理啊!

  • 相关阅读:
    无废话MVC入门教程五[Control与View交互]
    无废话MVC入门教程三[路由设置及视图入门]
    无废话MVC入门教程二[第一个小Demo]
    IDEA 插件开发
    慢慢学Linux驱动开发,第十章,GNU C的扩展
    《UNIX环境高级编程》编译问题彻底解决方案
    GNU make笔记
    outlook2003无法显示地址列表 无法打开与该地址列表的相关"联系人"文件夹解决方案
    慢慢学Linux驱动开发,第十二章,加入内核
    ADS: (Fatal)L6002U:Could not open file:..... & L6002
  • 原文地址:https://www.cnblogs.com/seniortestingdev/p/2540976.html
Copyright © 2020-2023  润新知