The content of element type "resultMap" must match "(constructor?,id*,result*,association",collection' discriminator?)"
时间: 2024-01-22 17:03:33 浏览: 29
这个错误提示是MyBatis中XML配置文件中的resultMap标签的格式错误导致的。resultMap标签用于将查询结果映射到Java对象的属性上。根据错误提示,resultMap标签的内容必须符合以下格式:
```
<resultMap id="resultMapId" type="resultMapType">
<constructor>
<!-- 构造方法参数映射 -->
</constructor>
<id property="id" column="id"/>
<!-- 主键映射 -->
<result property="name" column="name"/>
<!-- 普通属性映射 -->
<association property="associationProperty" resultMap="associationResultMapId"/>
<!-- 一对一关联映射 -->
<collection property="collectionProperty" resultMap="collectionResultMapId"/>
<!-- 一对多关联映射 -->
<discriminator javaType="discriminatorJavaType" column="discriminatorColumn">
<!-- 鉴别器 -->
</discriminator>
</resultMap>
```
请检查你的resultMap标签是否符合以上格式要求,尤其要注意标签的嵌套顺序和属性设置是否正确。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)