1. Create a new MyBatis folder in the src/main/resources/directory and put the Xxx.xml file in the folder
2. Configure in the Application.yml file:
MyBatis
Configuration
Mapunderscoretocamelcase:true
Mapperlocations:mybatis/*mapper.xml
3, in the DAO interface file annotated @mapper, note that the interface method on the SQL statement to remove
@Mapper Public Interfacemrinfomapper{/*** Query Mr Information on condition *@paramparam *@return */ PublicList<map<string, object>> findbycondition (map<string, object>param); /*** Get page display data *@paramparam *@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 is mi.ce= ' Y ' then ' ce ' end, '),"//+ "ifnull (case is mi.ne= ' Y ' Then ' ne ' End, '),"//+ "ifnull (case is mi.ptn= ' Y ' then ' ptn ' End, '),"//+ "ifnull (case is mi.rtn= ' Y ' then ' rtn ' End, '),"//+ "ifnull (case is 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>") PublicList4, write SQL in the Xxxmapper.xml file, note the NAMESAPCE value do not write wrong.
<?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 "><Mappernamespace= "Com.huawei.nos.nosimsys.dao.MrInfoMapper"><SelectID= "Findbycondition"ParameterType= "Map"Resulttype= "Map">SELECT * from Tb_mr_info TMI WHERE 1=1 and Tmi.table_flag=#{searchdate}<ifTest= "ProductList ! = null and ProductList! =" "> <foreachCollection= "ProductList"Item= "Item">and ${item}= ' Y '</foreach> </if></Select>
Springboot Configuring the Mapper path for MyBatis