zoukankan      html  css  js  c++  java
  • springboot配置mybatis的mapper路径

    1、在src/main/resources/目录下新建mybatis文件夹,将xxx.xml文件放入该文件夹内

    2、在application.yml文件中配置:

    mybatis:

      configuration:

        mapUnderscoreToCamelCase: true

      mapperLocations: mybatis/*Mapper.xml

    3、在Dao接口文件中加注解@Mapper,注意要将接口方法上的sql语句去掉

    @Mapper
    public interface MrInfoMapper
    {
        /**
         * 根据条件查询MR信息
         * @param param
         * @return
         */
        public List<Map<String, Object>> findByCondition(Map<String, Object> param);
        /**
         * 获取页面展示数据
         * @param param
         * @return
         */
        // @Select("<script>" + "SELECT" + " group_concat(id) id," + " max(mi.mr) mr," + " mi.intf_file,"
        // + " max(mi.area) area," + " max(mi.rversion) rversion," + " concat("
        // + " ifnull(case when mi.ce='Y' then 'CE ' end,''),"
        // + " ifnull(case when mi.ne='Y' then 'NE ' end,''),"
        // + " ifnull(case when mi.ptn='Y' then 'PTN ' end,''),"
        // + " ifnull(case when mi.rtn='Y' then 'RTN ' end,''),"
        // + " ifnull(case when mi.trans='Y' then 'TRANS ' end,'')" + ") products,"
        // + " group_concat(distinct mi.change_type) change_type," + " max(mi.table_flag) table_flag" + " FROM "
        // + " tb_mr_info mi " + "WHERE" + " mi.intf_file IS NOT NULL" + " AND mi.table_flag = #{searchDate} "
        // + "<if test="productList != null ">" + "<foreach item="item" collection="productList" >"
        // + " and ${item}='Y'" + "</foreach>" + "</if>" + "GROUP BY" + " mi.intf_file" + "</script>")
        public List<HashMap<String, String>> findDisplayData(Map<String, Object> param);

    4、在xxxmapper.xml文件中写SQL,注意namesapce值不要写错。

    <?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.huawei.nos.nosimsys.dao.MrInfoMapper">
    <select id="findByCondition" parameterType="map" resultType="map">
        SELECT
            *
        FROM
            tb_mr_info tmi
        WHERE 1=1
        AND tmi.table_flag=#{searchDate}
        <if test="productList != null and productList != ''">  
            <foreach collection="productList" item="item">
                and ${item}='Y'
            </foreach>
        </if>
    </select>
  • 相关阅读:
    window字体安装方法,fonts安装方法
    在Vmware虚拟机中安装Mac OS
    winbox教程
    eclipse activiti 使用 集成 插件
    高等数学 1
    电路 分析 学习 书 的 推荐
    eclipse 替代 keil (二) eclipse 和 jdk 安装
    eclipse 替代 keil (三) 新建项目
    Spark Stuctured Streaming(实时流计算:Structured Streaming) windows开发环境搭建
    Hadoop HA一键启动,一键关闭脚本
  • 原文地址:https://www.cnblogs.com/xyhero/p/d140b83306140135343d2a49816e9935.html
Copyright © 2011-2022 走看看