grain-Edu-Note part09 向mapper接口添加自定义功能,并将xml打包

写mapper

在这里插入图片描述
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ezerbel.grain.service.edu.mapper.SubjectMapper">

    <select id="selectNestedListByParentId" resultMap="nestedSubject">
        select id,title,sort from edu_subject where parent_id = #{parentId}
    </select>

    <resultMap id="nestedSubject" type="com.ezerbel.grain.service.edu.entity.vo.SubjectVo">
        <id property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="sort" column="sort"/>
        <!--   select语句传入参数为cloumn对应的id   -->
        <collection property="children"
                    column="id"
                    select="selectNestedListByParentId"
                    ofType="com.ezerbel.grain.service.edu.entity.vo.SubjectVo"/>
    </resultMap>

</mapper>

默认源码包内的xml不会被打包

在这里插入图片描述
在这里插入图片描述

maven添加源码包内xml打包配置

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <!--      不过滤掉          -->
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

yml 配置中指明mapper文件的所在位置

#mybatis日志
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:com/ezerbel/grain/service/edu/mapper/xml/*.xml
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值