`
wxb880114
  • 浏览: 683660 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Attribute "alias" is required and must be specified for element type "typeAlias"

 
阅读更多
Exception in thread "main" java.lang.ExceptionInInitializerError
at ibatis.conn.UserDAOImpl.findUserById(UserDAOImpl.java:20)
at ibatis.conn.TestDAO.main(TestDAO.java:38)
Caused by: java.lang.RuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Attribute "alias" is required and must be specified for element type "typeAlias".
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at ibatis.conn.IbatisUitl.<clinit>(IbatisUitl.java:27)
... 2 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Attribute "alias" is required and must be specified for element type "typeAlias".
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 4 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Attribute "alias" is required and must be specified for element type "typeAlias".
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 5 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Attribute "alias" is required and must be specified for element type "typeAlias".
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 9 more
Caused by: org.xml.sax.SAXParseException: Attribute "alias" is required and must be specified for element type "typeAlias".
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.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:1193)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1940)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:785)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
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:232)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 12 more
解决方法:
   由于typeAlias的标签中没有name,需要用alias。
<typeAlias name="user" type="model.User" />
   <typeAlias alias="user" type="model.User"/>



2.Exception in thread "main" java.lang.ExceptionInInitializerError
at ibatis.conn.UserDAOImpl.findUserById(UserDAOImpl.java:20)
at ibatis.conn.TestDAO.main(TestDAO.java:38)
Caused by: java.lang.RuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "flushOnExcute" must be declared.
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at ibatis.conn.IbatisUitl.<clinit>(IbatisUitl.java:27)
... 2 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "flushOnExcute" must be declared.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 4 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "flushOnExcute" must be declared.
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 5 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "flushOnExcute" must be declared.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 9 more
Caused by: org.xml.sax.SAXParseException: Element type "flushOnExcute" must be declared.
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.handleStartElement(XMLDTDValidator.java:1929)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:785)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
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:232)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 12 more

Exception in thread "main" java.lang.ExceptionInInitializerError
at ibatis.conn.UserDAOImpl.findUserById(UserDAOImpl.java:20)
at ibatis.conn.TestDAO.main(TestDAO.java:38)
Caused by: java.lang.RuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:49)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at ibatis.conn.IbatisUitl.<clinit>(IbatisUitl.java:27)
... 2 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:46)
... 4 more
Caused by: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:123)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:84)
at com.ibatis.common.xml.NodeletParser.process(NodeletParser.java:102)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:72)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:51)
... 5 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapParser.parse(SqlMapParser.java:40)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser$10.process(SqlMapConfigParser.java:270)
at com.ibatis.common.xml.NodeletParser.processNodelet(NodeletParser.java:121)
... 9 more
Caused by: org.xml.sax.SAXParseException: The string "--" is not permitted within comments.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1427)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:787)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.java:1040)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:945)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
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:232)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 12 more

解决方法:
不能在配置文件开头注释,删除红色注释部分。
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">

<!-- namespace="User"无作用-->

<sqlMap namespace="User">
<!-- 模块配置-->
<typeAlias alias="user" type="model.User"/>

<cacheModel id="userCache" type="LRU">
<flushInterval hours="24"/>
<property name="size" value="1000"/>
</cacheModel>
0
4
分享到:
评论

相关推荐

    ibatis与spring的整合

    在整合iBATIS和Spring的过程中,主要目标是利用Spring的IOC(Inversion of Control)容器来管理和协调数据访问层(DAO)以及事务处理,同时利用iBATIS作为SQL映射框架,提供灵活的数据库操作。以下将详细阐述整合的...

    Multiple Attribute Decision Making Methods and Applications 2011

    3. 逼近理想解排序法(Technique for Order Preference by Similarity to Ideal Solution, TOPSIS):这种方法基于方案与理想解(最优属性值构成的虚拟方案)和非理想解(最差属性值构成的虚拟方案)之间的相对接近...

    SSD7 选择题。Multiple-Choice

    For two tables to be union compatible, the tables should be the same with respect to which of the following? (a) keys (b) cardinality (c) name (d) degree Correct answer is (d) Your ...

    Tomcat ssl报错Connector attribute SSLCertificateFile must be defined when using SSL with APR解决方法

    主要介绍了Tomcat ssl报错Connector attribute SSLCertificateFile must be defined when using SSL with APR解决方法,需要的朋友可以参考下

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    解决Python中报错TypeError: must be str, not bytes问题

    ### 解决Python中报错TypeError: must be str, not bytes问题 #### 一、问题背景与常见场景 在Python编程过程中,尤其是处理文件操作时,可能会遇到“TypeError: must be str, not bytes”这一错误。这通常发生在...

    数位板压力测试

    Programming is easiest when the amount of knowledge and effort required matches the task at hand. Writing simple programs should require only a few lines of code and a minimal understanding of the en-...

    javafx-8u152-apidocs-api

    Note that the start method is abstract and must be overridden. The init and stop methods have concrete implementations that do nothing. Calling Platform.exit() is the preferred way to explicitly ...

    Devart LinqConnect 3.1

    Capability for setting diagram options either globally for all diagram documents or separately for a particular one is implemented: the Diagram Appearance and Printing options can now be set through ...

    Attribute Weighting for Averaged One-Dependence Estimators

    Averaged One-Dependence Estimators (AODE) is one of supervised learning algorithm, which relaxes the conditional independent assumption that working on the standard naive Bayes learner. The AODE has ...

    Multiple Attribute Decision Making — Methods and Applications1981

    Multiple Attribute Decision Making — Methods and Applications A State-of-the-Art Survey 多属性决策-方法和应用最先进的调查

    简单计算器的代码

    【标题】"简单计算器的代码"涉及的是创建一个基本的计算器应用,这通常是一个初学者在学习iOS开发时会遇到的项目。这个项目的核心在于理解用户界面(UI)的构建和事件处理,以及如何通过代码实现数学计算逻辑。...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    On the other hand, you must include the header file for Foo if your class subclasses Foo or has a data member of type Foo. Sometimes it makes sense to have pointer (or better, scoped_ptr) members ...

    Category and Attribute Prediction Benchmark

    2016-08-08 The data and labels of the attribute prediction benchmark are released without encription (password). If Dropbox are not accessable, please download the dataset using Google Drive or Baidu ...

    erlanghandbook

    - **`-module(Module)`**: This attribute defines the name of the module and must be specified first. The module name should match the filename without the `.erl` extension. - **`-export([Func1/Arity1,...

    http://www.w3.org/TR/html4/loose.dtd

    for presentation attribute and elements is required. HTML 4 includes mechanisms for style sheets, scripting, embedding objects, improved support for right to left and mixed direction text, ...

    JSP Simple Examples

    All the headers are optional except Content-length, which is required only for POST request. Java class in JSP To use the class inside the jsp page we need to create an object of the class by using...

Global site tag (gtag.js) - Google Analytics