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>
springboot配置mybatis的mapper路径的更多相关文章
- springboot 配置mybatis 配置mapper.xml
# 插件 进行配置 也可以用yml # 1. 配置 Tomcat 修改端口号 server.port=8848 server.context-path=/zxf #2.配置数据源 spring.dat ...
- SpringBoot配置mybatis
一直都说SpringBoot是零配置,当然,真正实现零配置是不可能的,但是在配置mybatis这里真的是太简单了,哈哈,下面我们一起看一下. 1.先导入基于SpringBoot的mybatis依赖包 ...
- springboot 使用mybatis 通用Mapper,pagehelper
首先需要maven导入需要的包,这里用的是sqlserver,druid,jtds连接数据库 <dependency> <groupId>com.alibaba</gro ...
- Springboot集成mybatis通用Mapper与分页插件PageHelper
插件介绍 通用 Mapper 是一个可以实现任意 MyBatis 通用方法的框架,项目提供了常规的增删改查操作以及 Example 相关的单表操作.通用 Mapper 是为了解决 MyBatis 使用 ...
- springboot整合mybatis通用Mapper
参考: https://blog.csdn.net/x18707731829/article/details/82814095 https://www.jianshu.com/p/6d2103451d ...
- springboot配置静态资源访问路径
其实在springboot中静态资源的映射文件是在resources目录下的static文件夹,springboot推荐我们将静态资源放在static文件夹下,因为默认配置就是classpath:/s ...
- SpringBoot配置本地文件映射路径
1.前言 在springboot的项目中,如果需要通过项目方式访问本地磁盘的文件,不仅可以使用nginx代理的方式,还可以使用springboot配置的方式进行访问. 实例原因说明:由于上传的图片是要 ...
- springboot整合mybatis。mapper.xml资源文件放置到resources文件夹下的配置&别名使用配置
- 【记录】spring/springboot 配置mybatis打印sql
======================springboot mybatis 打印sql========================================== 方式 一: ##### ...
随机推荐
- IDEA中新建Module时Module name、Content root、Module file location的含义
如下图测试: 最开始默认情况下,Content root.Module file location两行,最末尾的数据跟Module name是相同的. 现在对三行数据,强制进行不同的命名,Finish ...
- 【刷题】LOJ 6004 「网络流 24 题」圆桌聚餐
题目描述 假设有来自 \(n\) 个不同单位的代表参加一次国际会议.每个单位的代表数分别为 \(r_i\) .会议餐厅共有 \(m\) 张餐桌,每张餐桌可容纳 \(c_i\) 个代表就餐. 为了使 ...
- 利用powerful number求积性函数前缀和
好久没更博客了,先水一篇再说.其实这个做法应该算是杜教筛的一个拓展. powerful number的定义是每个质因子次数都 $\geq 2$ 的数.首先,$\leq n$ 的powerful num ...
- 学习Spring Boot:(十三)配置 Shiro 权限认证
经过前面学习 Apache Shiro ,现在结合 Spring Boot 使用在项目里,进行相关配置. 正文 添加依赖 在 pom.xml 文件中添加 shiro-spring 的依赖: <d ...
- 【BZOJ1449】[JSOI2009]球队收益(网络流,费用流)
[BZOJ1449][JSOI2009]球队收益(网络流,费用流) 题面 BZOJ 洛谷 题解 首先对于一支队伍而言,总共进行多少场比赛显然是已知的,假设是\(n_i\)场,那么它的贡献是:\(C_i ...
- 【BZOJ3745】Norma(CDQ分治)
[BZOJ3745]Norma(CDQ分治) 题面 BZOJ 洛谷 题解 这种问题直接做不好做,显然需要一定的优化.考虑\(CDQ\)分治. 现在唯一需要考虑的就是跨越当前中间节点的所有区间如何计算答 ...
- Appium+python自动化获取toast消息(windows版)的方法
原来用的Appium1.5.3GUI版本,那为什么升级呢? 为了兼容最新版本的iOS10和Android7 Xcode8升级后,将不支持使用UIAutomation,而是改为使用XCUITest了,并 ...
- 解题:UOJ #46 玄学
题面 二进制分组,修改把区间拆开丢在后面,合并的时候归并最后两块:查询在对应节点上二分答案 #include<cstdio> #include<cstring> #includ ...
- 洛谷P2672 推销员
沙雕贪心...... 我一开始想的是倒着来,每次减去一个. 然后我们就有两个决策:去掉最后一个/去掉前面某一个. 然后第一个决策用并查集维护,第二个决策用线段树即可.仔细想想觉得普及组不会考这种东西, ...
- mybatis的面试一对一,一对多,多对多的mapper.xml配置
使用springboot完成一对一,一对多: https://blog.csdn.net/KingBoyWorld/article/details/78966789 传统的mapper文件中的一对一, ...