Springboot与mybatis整合
在application.properties文件中
mybatis.type-aliases-package=com.baidu.*.dao
Dao层
@Mapper
public interface ProvMarkSuppDao {
@Select("<script>"
+ "SELECT "
+ "sett_mmonth"
+ " FROM dmk_cgp_pg_rpt a "
+ " WHERE 1=1 "
+ "<if test='settMonth != null '>"
+ " and sett_month = #{settMonth,jdbcType=VARCHAR} "
+ "</if>"
+ " ORDER BY sett_month ASC "
+ "</script>")
@Results(id="getMasterAgreeExport", value= {@Result(property = "settMonth", column = "sett_month")
})
List<MasterAgreeBean> getMasterAgreeExport(
@Param("settMonth") String settMonth
);
}
实体bean:
@AllArgsConstructor:全部参数的构造函数
@NoArgsConstructor:无参构造函数
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MasterAgreeBean {
private String settMonth;
private String provName;
private String operCode;
private String operName;
private String channelId;
private String dgpFees;
}
这样就不用写mapping.xml