问题描述
<resultMapid="accountTest"class="com.yeepay.entity.Account"><resultproperty="id"column="id"/><resultproperty="cardType"column="card_type"/><resultproperty="userID"column="user_id"/><resultproperty="balance"column="balance"/><resultproperty="overdraftDegrees"column="overdraft_degrees"/></resultMap><resultMapclass="user"id="resultAllUser"><resultproperty="id"column="id"/><resultproperty="name"column="name"/><resultproperty="email"column="email"/><resultproperty="password"column="password"/><resultproperty="account"column="id"resultMap="accountTest"/><!--把要使用的字段值传过去--></resultMap><statementid="selectUserbyIdJoin"resultMap="resultAllUser"><![CDATA[selectu.*,a.*fromtable_ibatis_userujointable_ibatis_accountaonu.id=a.user_idwhereu.id=#value#]]></statement>异常:com.ibatis.sqlmap.client.SqlMapException:TherewasanerrorwhilebuildingtheSqlMapinstance.---Theerroroccurredincom/yeepay/entity/User.xml.---TheerroroccurredwhileloadingtheSQLMapresource.---Cause:com.ibatis.sqlmap.client.SqlMapException:XMLParserError.Cause:org.xml.sax.SAXException:Error:URI=nullLine=81:Attribute"resultMap"mustbedeclaredforelementtype"result".Causedby:org.xml.sax.SAXException:Error:URI=nullLine=81:Attribute"resultMap"mustbedeclaredforelementtype"result".Causedby:com.ibatis.sqlmap.client.SqlMapException:XMLParserError.Cause:org.xml.sax.SAXException:Error:URI=nullLine=81:Attribute"resultMap"mustbedeclaredforelementtype"result".Causedby:org.xml.sax.SAXException:Error:URI=nullLine=81:Attribute"resultMap"mustbedeclaredforelementtype"result".atcom.ibatis.sqlmap.engine.builder.xml.XmlSqlMapClientBuilder.buildSqlMap(XmlSqlMapClientBuilder.java:243)atcom.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:61)atcom.yeepay.dao.UserDaoImpl.<clinit>(UserDaoImpl.java:26)atcom.yeepay.test.UserTest.init(UserTest.java:25)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(UnknownSource)atsun.reflect.DelegatingMethodAccessorImpl.invoke(UnknownSource)atjava.lang.reflect.Method.invoke(UnknownSource)atorg.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)atorg.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)atorg.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)atorg.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)atorg.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)atorg.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)atorg.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)atorg.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)atorg.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)atorg.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)atorg.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)atorg.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)atorg.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)Causedby:com.ibatis.sqlmap.client.SqlMapException:XMLParserError.Cause:org.xml.sax.SAXException:Error:URI=nullLine=81:Attribute"resultMap"mustbedeclaredforelementtype"result".
解决方案
解决方案二:
sqlMap.xml配置文件错误了
解决方案三:
仔细检查一下配置文件...
解决方案四:
resultMapclass="user"这个user配置全路径,找不到
解决方案五:
那里错啦请指教
解决方案六:
<?xmlversion="1.0"encoding="GBK"?><!DOCTYPEsqlMapPUBLIC"-//iBATIS.com//DTDSQLMap2.0//EN""http://www.ibatis.com/dtd/sql-map-2.dtd"><sqlMap><!--为类起一个别名方便调用--><typeAliasalias="user"type="com.yeepay.entity.User"/><typeAliasalias="account"type="com.yeepay.entity.Account"/><resultMapid="accountTest"class="com.yeepay.entity.Account"><resultproperty="id"column="id"/><resultproperty="cardType"column="card_type"/><resultproperty="userID"column="user_id"/><resultproperty="balance"column="balance"/><resultproperty="overdraftDegrees"column="overdraft_degrees"/></resultMap><resultMapclass="user"id="resultAllUser"><resultproperty="id"column="id"/><resultproperty="name"column="name"/><resultproperty="email"column="email"/><resultproperty="password"column="password"/><resultproperty="account"column="id"resultMap="accountTest"/><!--把要使用的字段值传过去--></resultMap><statementid="selectUserbyIdJoin"resultMap="resultAllUser"><![CDATA[selectu.*,a.*fromtable_ibatis_userujointable_ibatis_accountaonu.id=a.user_idwhereu.id=#value#]]></statement>
解决方案七:
resultAllUser这个resultMap没有class并且whereu.id=#value#没有para
解决方案八:
关键是读取配置文件时就错啦,两个resultMap能那样配置吗请高手指教
解决方案九:
<resultproperty="account"column="id"resultMap="accountTest"/>这句有错误吧.应该是<resultproperty="account"column="id"select="select_account_Id"/><selectid="select_account_Id"parameterClass="java.lang.String"resultMap="accountTest">SELECTid,cardType,user_id,balance,overdraft_degreesfromaccount表whereaccountId=#value#</select>
解决方案十:
<resultproperty="account"column="id"resultMap="accountTest"/>有误
解决方案十一:
resultproperty="account"column="id"resultMap="accountTest"/>改为:<resultproperty="account"column="id"select="selectUserbyIdJoin"/>