请问mybatis plus 如何使用 xml写自定义sql语句不报错?

我的yml文件

# Mybatis-plus配置

mybatis-plus:

#配置Mapper映射文件

mapper-locations: classpath*:/mapper/*Mapper.xml

# 配置MyBatis数据返回类型别名(默认别名是类名)

type-aliases-package: com.quanneng.xc_mall.entity,com.quanneng.xc_mall.vo

configuration:

# 自动驼峰命名

map-underscore-to-camel-case: false

#开启sql日志

log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

我的mapper文件

位置在:src/main/java/com/quanneng/xc_mall/mapper/ComplainMapper.java

package com.quanneng.xc_mall.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import com.quanneng.xc_mall.entity.Complain;

import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Param;

/**

* (Complain)表数据库访问层

*

* @author szl

* @since 2022-12-08 11:15:02

*/

@Mapper

public interface ComplainMapper extends BaseMapper<Complain> {

Integer countByMchid(@Param("mchid") Integer mchid);

}

我的xml文件

位置在:src/main/resources/mapper/ComplainMapper.xml

<?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.quanneng.xc_mall.mapper.ComplainMapper">

<resultMap type="com.quanneng.xc_mall.entity.Complain" id="complainMap">

<result property="id" column="id"/>

<result property="oid" column="oid"/>

<result property="goodid" column="goodid"/>

<result property="orderid" column="orderid"/>

<result property="type" column="type"/>

<result property="contact" column="contact"/>

<result property="tel" column="tel"/>

<result property="ip" column="ip"/>

<result property="addtime" column="addtime"/>

<result property="updatetime" column="updatetime"/>

<result property="evidence" column="evidence"/>

<result property="remark" column="remark"/>

<result property="account" column="account"/>

<result property="realname" column="realname"/>

<result property="code" column="code"/>

<result property="mchid" column="mchid"/>

<result property="isDj" column="is_dj"/>

<result property="xjMchid" column="xj_mchid"/>

<result property="isState" column="is_state"/>

<result property="resultRemark" column="result_remark"/>

<result property="resultStatus" column="result_status"/>

<result property="refundStatus" column="refund_status"/>

<result property="refundTime" column="refund_time"/>

<result property="adminId" column="admin_id"/>

<result property="isHide" column="is_hide"/>

<result property="channelId" column="channel_id"/>

<result property="providerId" column="provider_id"/>

<result property="refundMoney" column="refund_money"/>

<result property="sjMchRefundMoney" column="sj_mch_refund_money"/>

<result property="sellerMchRefundMoney" column="seller_mch_refund_money"/>

<result property="sxfPtRefundMoney" column="sxf_pt_refund_money"/>

<result property="isAsyncStatus" column="is_async_status"/>

</resultMap>

<select id="countByMchid" resultType="java.lang.Integer">

SELECT COUNT(1)

FROM `xc_complain`

WHERE mchid = #{mchid}

</select>

</mapper>

提示:RuntimeException:Invalid bound statement (not found): com.quanneng.xc_mall.mapper.ComplainMapper.countByMchid


回答:

mapper-locations: classpath*:mapper/*Mapper.xml

路径修改一下试试,mapper前面是用相对的


回答:

如果集成了spring,确认是否有配置@MapperScan注解对Mapper进行扫描


回答:

这边建议你好好学下mybaits

以上是 请问mybatis plus 如何使用 xml写自定义sql语句不报错? 的全部内容, 来源链接: utcz.com/p/944890.html

回到顶部