Java從服務(wù)端下載Excel模板文件的兩種方法
本文實(shí)例為大家分享了Java從服務(wù)端下載Excel模板文件的具體實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
方法一 (2021年01月更新)
生成excel模板
@RequestMapping("/downloadExcel") public void downloadExcel(HttpServletResponse response, HttpServletRequest request) { ? ? ? ? String [] excelHeader = {"姓名","手機(jī)號(必填)","渠道名","產(chǎn)品名","手機(jī)操作系統(tǒng)(IOS/安卓)","是否是XX數(shù)據(jù)"}; ? ? ? ? List<Object> list = new ArrayList<>(); ? ? ? ? Object[] obj1 = {"張三","173*****311?","a1","A","IOS","是"}; ? ? ? ? Object[] obj2 = {"李四","138*****742","a2","B","安卓","否"}; ? ? ? ? list.add(obj1); ? ? ? ? list.add(obj2); ? ? ? ? FileExport.exportExcel(excelHeader, list, "XXX模板", response, request); ? ? }
FileExport工具類:
package com.abc.common.utils.file; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; /** ?* 文件導(dǎo)出工具 ?* @author abc ?* @date 2019/01/08 ?*/ public class FileExport { ?? ? ?? ?private static final Logger logger = LoggerFactory.getLogger(FileExport.class); ? ? /** CSV文件列分隔符 */ ? ? private static final String CSV_COLUMN_SEPARATOR = ","; ? ? private static final String CSV_COLUM_TABLE = "\t"; ? ? /** CSV文件列分隔符 */ ? ? private static final String CSV_RN = "\r\n"; ?? ?/** ?? ? * 導(dǎo)出Excel文件 ?? ? *? ?? ? * @param excelHeader ?? ? * ? ? ? ? ? ?導(dǎo)出文件中表格頭 ?? ? * @param list ?? ? * ? ? ? ? ? ?導(dǎo)出的內(nèi)容 ?? ? * @param response ?? ? * ? ? ? ? ? ?HttpServletResponse對象,用來獲得輸出流向客戶端寫導(dǎo)出的文件 ?? ? * @param sheetName ?? ? * ? ? ? ? ? ?Excel的sheet名稱,加上時間戳作為導(dǎo)出文件的名稱 ?? ? */ ? ? public static void exportExcel(String [] excelHeader, List<Object> list, String sheetName, HttpServletResponse response, HttpServletRequest request) { ?? ??? ?HSSFWorkbook wb = new HSSFWorkbook(); ?? ??? ?HSSFSheet sheet = wb.createSheet(sheetName); ?? ??? ?HSSFRow row = sheet.createRow((int) 0); ? ? ? ? /******設(shè)置單元格是否顯示網(wǎng)格線******/ ?? ??? ?sheet.setDisplayGridlines(false); ?? ??? ? ?? ??? ?/******設(shè)置頭單元格樣式******/ ?? ??? ?HSSFCellStyle style = wb.createCellStyle(); ?? ??? ?style.setAlignment(HorizontalAlignment.CENTER); ?? ??? ?Font fontHeader = wb.createFont(); ?? ??? ?fontHeader.setBold(true); ?? ??? ?fontHeader.setFontHeight((short) 240); ?? ??? ?style.setFont(fontHeader); ?? ??? ?style.setBorderBottom(BorderStyle.THIN); ?? ??? ?style.setBorderLeft(BorderStyle.THIN); ?? ??? ?style.setBorderRight(BorderStyle.THIN); ?? ??? ?style.setBorderTop(BorderStyle.THIN); ?? ??? ? ?? ??? ?/******設(shè)置頭內(nèi)容******/ ?? ??? ?for (int i = 0; i < excelHeader.length; i++) { ?? ??? ??? ?HSSFCell cell = row.createCell(i); ?? ??? ??? ?cell.setCellValue(" ?" +excelHeader[i] + " ?"); ?? ??? ??? ?cell.setCellStyle(style);?? ??? ??? ? ?? ??? ?} ?? ? ? ? ?? ?? ??? ?/******設(shè)置內(nèi)容單元格樣式******/ ?? ??? ?HSSFCellStyle styleCell = wb.createCellStyle(); ?? ??? ?Font fontCell = wb.createFont(); ?? ??? ?fontCell.setColor(HSSFColor.BLACK.index); ?? ??? ?styleCell.setAlignment(HorizontalAlignment.CENTER); ?? ??? ?styleCell.setFont(fontCell); ?? ??? ?styleCell.setBorderBottom(BorderStyle.THIN); ?? ??? ?styleCell.setBorderLeft(BorderStyle.THIN); ?? ??? ?styleCell.setBorderRight(BorderStyle.THIN); ?? ??? ?styleCell.setBorderTop(BorderStyle.THIN); ? ? ? ? /******設(shè)置單元格內(nèi)容******/ ?? ??? ?for (int i = 0; i < list.size(); i++) { ?? ??? ??? ?row = sheet.createRow(i + 1); ?? ??? ??? ?/******設(shè)置行高******/ ?? ??? ??? ?row.setHeightInPoints(20); ?? ??? ??? ?Object[] obj = (Object[]) list.get(i);?? ??? ??? ? ?? ??? ??? ?for (int j = 0; j < excelHeader.length; j++) { ?? ??? ??? ??? ?styleCell.setWrapText(false); ? ? ? ? ? ? ?? ?HSSFCell cell = row.createCell(j); ?? ??? ??? ??? ?if (obj[j] != null){ ?? ??? ??? ??? ??? ? cell.setCellValue(obj[j].toString()); ?? ??? ??? ??? ?}else{ ?? ??? ??? ??? ??? ?cell.setCellValue("");? ?? ??? ??? ??? ?}?? ??? ??? ? ?? ??? ??? ??? ?//if(obj[j].toString().length()>20) ?? ??? ??? ??? ?//?? ?styleCell.setWrapText(true); ?? ??? ??? ??? ?cell.setCellStyle(styleCell); ?? ??? ??? ??? ?sheet.autoSizeColumn(j); ? ? ? ? ? ? } ?? ? ? ? ? }? ?? ??? ? ?? ??? ?OutputStream ouputStream = null; ?? ??? ?try { ?? ??? ??? ? ?? ??? ??? ?String encoding = "UTF-8"; ?? ??? ??? ?/** 獲取瀏覽器相關(guān)的信息 */ ?? ??? ??? ?String userAgent = request.getHeader("user-agent"); ?? ??? ??? ?/** 判斷是否為msie瀏覽器 */ ?? ??? ??? ?if (userAgent.toLowerCase().indexOf("msie") != -1){ ?? ??? ??? ??? ? encoding = "gbk"; ?? ??? ??? ?} ? ? ? ? ? ? response.setCharacterEncoding(encoding); ?? ? ? ? ? ?response.setContentType("application/vnd.ms-excel");? ?? ? ? ? ? ?String fileName = sheetName; ?? ? ? ? ? ?SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHMMSS"); ?? ? ? ? ? ?fileName += (dateFormat.format(new Date())).toString()+".xls"; ?? ? ? ? ? ?response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, encoding)); ?? ? ? ? ? ?ouputStream = response.getOutputStream(); ?? ?? ? ? ? ? ?wb.write(ouputStream); ? ?? ?? ? ? ? ? ?ouputStream.flush(); ? ?? ??? ?} catch (Exception e) { ?? ??? ??? ?e.printStackTrace(); ?? ??? ?} finally { ? ? ? ? ?? ?try { ? ? ? ? ?? ??? ?if(ouputStream!=null) { ?? ??? ??? ??? ??? ?ouputStream.close(); ?? ??? ??? ??? ?} ?? ??? ??? ?} catch (IOException e) { ?? ??? ??? ??? ?e.printStackTrace(); ?? ??? ??? ?} ? ? ? ? } ? ? } ? ? /** ? ? ?* 導(dǎo)出CSV文件 ? ? ?* @param dataList 集合數(shù)據(jù) ? ? ?* @param colNames 表頭部數(shù)據(jù) ? ? ?* @param mapKey 查找的對應(yīng)數(shù)據(jù) ? ? ?*/ ? ? public static boolean doExport(List<Map<String, Object>> dataList, String colNames, String mapKey, OutputStream os) { ? ? ? ? try { ? ? ? ? ? ? StringBuffer buf = new StringBuffer(); ? ? ? ? ? ? String[] colNamesArr = null; ? ? ? ? ? ? String[] mapKeyArr = null; ? ? ? ? ? ? colNamesArr = colNames.split(","); ? ? ? ? ? ? mapKeyArr = mapKey.split(","); ? ? ? ? ? ? /******完成數(shù)據(jù)csv文件的封裝******/ ? ? ? ? ? ? /******輸出列頭******/ ? ? ? ? ? ? for (int i = 0; i < colNamesArr.length; i++) { ? ? ? ? ? ? ? ? buf.append(colNamesArr[i]).append(CSV_COLUMN_SEPARATOR); ? ? ? ? ? ? } ? ? ? ? ? ? buf.append(CSV_RN); ? ? ? ? ? ? if (null != dataList) { ? ? ? ? ? ? ?? ?/******輸出數(shù)據(jù)******/ ? ? ? ? ? ? ? ? for (int i = 0; i < dataList.size(); i++) { ? ? ? ? ? ? ? ? ? ? for (int j = 0; j < mapKeyArr.length; j++) { ? ? ? ? ? ? ? ? ? ? ? ? buf.append(dataList.get(i).get(mapKeyArr[j])).append(CSV_COLUM_TABLE).append(CSV_COLUMN_SEPARATOR); ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? buf.append(CSV_RN); ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? /******寫出響應(yīng)******/ ? ? ? ? ? ? os.write(buf.toString().getBytes("GBK")); ? ? ? ? ? ? os.flush(); ? ? ? ? ? ? return true; ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? logger.error("doExport錯誤...", e); ? ? ? ? } ? ? ? ? return false; ? ? } ? ?? ? ? /** ? ? ?* 設(shè)置響應(yīng)格式 ? ? ?* @param fileName ? ? ?* @param response ? ? ?* @throws UnsupportedEncodingException ? ? ?*/ ? ? public static void responseSetProperties(String fileName, HttpServletResponse response) throws UnsupportedEncodingException { ? ? ? ? /******設(shè)置文件后綴******/ ? ? ? ? SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); ? ? ? ? String fn = fileName + sdf.format(new Date()).toString() + ".csv"; ? ? ? ? /******讀取字符編碼******/ ? ? ? ? String utf = "UTF-8"; ? ? ? ? /******設(shè)置響應(yīng)******/ ? ? ? ? response.setContentType("application/ms-txt.numberformat:@"); ? ? ? ? response.setCharacterEncoding(utf); ? ? ? ? response.setHeader("Pragma", "public"); ? ? ? ? response.setHeader("Cache-Control", "max-age=30"); ? ? ? ? response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fn, utf)); ? ? } }
導(dǎo)出CSV文件
@GetMapping("/exportFailureRecord") public void exportFailureRecord(String batchNumber, HttpServletResponse response) { ? ? ? ? if (StringUtils.isBlank(batchNumber)) { ? ? ? ? ? ? log.warn("失敗記錄導(dǎo)出失敗,批次號為空..."); ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? //這里根據(jù)你的業(yè)務(wù)查詢出數(shù)據(jù) ? ? ? ? List<ImportFailureRecord> list = importFailureRecordService.selectList(new EntityWrapper<ImportFailureRecord>() ? ? ? ? ? ? ? ? .eq("is_delete", 0) ? ? ? ? ? ? ? ? .eq("batch_number", batchNumber)); ? ? ? ? if (CollectionUtil.isEmpty(list)) { ? ? ? ? ? ? log.warn("未查詢到可導(dǎo)出的數(shù)據(jù)..."); ? ? ? ? ? ? return; ? ? ? ? } ? ? ? ? log.info("===========查詢到{}條可導(dǎo)出數(shù)據(jù)==============", list.size()); ? ? ? ? String sTitle = "用戶姓名,手機(jī)號,失敗原因"; ? ? ? ? String fName = "xxx失敗記錄數(shù)據(jù)_"; ? ? ? ? String mapKey = "userName,userPhone,failureReason"; ? ? ? ? List<Map<String, Object>> dataList = new ArrayList<>(); ? ? ? ? for (ImportFailureRecord data : list) { ? ? ? ? ? ? Map<String, Object> map = new HashMap<>(); ? ? ? ? ? ? map.put("userName", data.getUserName() == null ? "" : data.getUserName()); ? ? ? ? ? ? map.put("userPhone", data.getUserPhone() == null ? "" : data.getUserPhone()); ? ? ? ? ? ? map.put("failureReason", data.getFailureReason() == null ? "" : data.getFailureReason()); ? ? ? ? ? ? dataList.add(map); ? ? ? ? } ? ? ? ? try (final OutputStream os = response.getOutputStream()) { ? ? ? ? ? ? log.info("=============失敗記錄導(dǎo)出開始============"); ? ? ? ? ? ? FileExport.responseSetProperties(fName, response); ? ? ? ? ? ? FileExport.doExport(dataList, sTitle, mapKey, os); ? ? ? ? ? ? log.info("=============失敗記錄導(dǎo)出結(jié)束============"); ? ? ? ? } catch (Exception e) { ? ? ? ? ? ? log.error("導(dǎo)出失敗記錄數(shù)據(jù)失敗", e); ? ? ? ? } ? ? }
方法二
/** ?* 描述:下載外部案件導(dǎo)入模板 ?* @param response ?* @param request ?* @author songfayuan ?* 2018年6月7日下午5:03:59 ?*/ ?? ?@RequestMapping("/downloadExcel") ?? ?@ResponseBody ?? ?public void downloadExcel(HttpServletResponse response,HttpServletRequest request) { ?? ??? ?//方法一:直接下載路徑下的文件模板(這種方式貌似在SpringCloud和Springboot中,打包成JAR包時,無法讀取到指定路徑下面的文件,不知道記錯沒,你們可以自己嘗試下!?。。? ?? ??? ?try { ? ? ? ? ? ? //獲取要下載的模板名稱 ? ? ? ? ? ? String fileName = "ApplicationImportTemplate.xlsx"; ? ? ? ? ? ? //設(shè)置要下載的文件的名稱 ? ? ? ? ? ? response.setHeader("Content-disposition", "attachment;fileName=" + fileName); ? ? ? ? ? ? //通知客服文件的MIME類型 ? ? ? ? ? ? response.setContentType("application/vnd.ms-excel;charset=UTF-8"); ? ? ? ? ? ? //獲取文件的路徑 ? ? ? ? ? ? String filePath = getClass().getResource("/template/" + fileName).getPath(); ? ? ? ? ? ? FileInputStream input = new FileInputStream(filePath); ? ? ? ? ? ? OutputStream out = response.getOutputStream(); ? ? ? ? ? ? byte[] b = new byte[2048]; ? ? ? ? ? ? int len; ? ? ? ? ? ? while ((len = input.read(b)) != -1) { ? ? ? ? ? ? ? ? out.write(b, 0, len); ? ? ? ? ? ? } ? ? ? ? ? ? //修正 Excel在“xxx.xlsx”中發(fā)現(xiàn)不可讀取的內(nèi)容。是否恢復(fù)此工作薄的內(nèi)容?如果信任此工作簿的來源,請點(diǎn)擊"是" ? ? ? ? ? ? response.setHeader("Content-Length", String.valueOf(input.getChannel().size())); ? ? ? ? ? ? input.close(); ? ? ? ? ? ? //return Response.ok("應(yīng)用導(dǎo)入模板下載完成"); ? ? ? ? } catch (Exception ex) { ? ? ? ? ? ? logger.error("getApplicationTemplate :", ex); ? ? ? ? ? ? //return Response.ok("應(yīng)用導(dǎo)入模板下載失?。?); ? ? ? ? } ?? ??? ? ?? ??? ? ?? ??? ?//方法二:可以采用POI導(dǎo)出excel,但是比較麻煩(這里類似方法一) ?? ??? ?/*try { ?? ??? ??? ?Workbook workbook = new HSSFWorkbook(); ?? ??? ??? ?request.setCharacterEncoding("UTF-8"); ?? ? ? ? ? ?response.setCharacterEncoding("UTF-8"); ?? ? ? ? ? ?response.setContentType("application/x-download"); ?? ? ?? ? ? ? ? ? ?? ? ? ? ? ?String filedisplay = "導(dǎo)入模板.xls"; ?? ? ? ?? ?? ? ? ? ? ?filedisplay = URLEncoder.encode(filedisplay, "UTF-8"); ?? ? ? ? ? ?response.addHeader("Content-Disposition", "attachment;filename="+ filedisplay); ?? ? ? ? ? ? ?? ??? ??? ?// 第二步,在webbook中添加一個sheet,對應(yīng)Excel文件中的sheet ? ?? ??? ??? ?Sheet sheet = workbook.createSheet("導(dǎo)入模板"); ?? ??? ??? ?// 第三步,在sheet中添加表頭第0行 ?? ??? ??? ?Row row = sheet.createRow(0); ?? ??? ??? ?// 第四步,創(chuàng)建單元格,并設(shè)置值表頭 設(shè)置表頭居中? ?? ??? ??? ?CellStyle style = workbook.createCellStyle(); ? ?? ? ? ? ? ?style.setAlignment(CellStyle.ALIGN_CENTER); // 創(chuàng)建一個居中格式? ?? ??? ??? ? ?? ??? ??? ?Cell cell = row.createCell(0); ? ?? ? ? ? ? ?cell.setCellValue("商品名稱"); ? ?? ? ? ? ? ?cell.setCellStyle(style);? ?? ? ? ? ? ?sheet.setColumnWidth(0, (25 * 256)); ?//設(shè)置列寬,50個字符寬 ?? ? ? ? ? ? ?? ? ? ? ? ?cell = row.createCell(1); ? ?? ? ? ? ? ?cell.setCellValue("商品編碼"); ? ?? ? ? ? ? ?cell.setCellStyle(style);? ?? ? ? ? ? ?sheet.setColumnWidth(1, (20 * 256)); ?//設(shè)置列寬,50個字符寬 ?? ? ? ? ? ? ?? ? ? ? ? ?cell = row.createCell(2); ? ?? ? ? ? ? ?cell.setCellValue("商品價格"); ? ?? ? ? ? ? ?cell.setCellStyle(style); ? ?? ? ? ? ? ?sheet.setColumnWidth(2, (15 * 256)); ?//設(shè)置列寬,50個字符寬 ?? ? ? ? ? ? ?? ? ? ? ? ?cell = row.createCell(3); ? ?? ? ? ? ? ?cell.setCellValue("商品規(guī)格"); ? ?? ? ? ? ? ?cell.setCellStyle(style); ? ?? ? ? ? ? ?sheet.setColumnWidth(3, (15 * 256)); ?//設(shè)置列寬,50個字符寬 ?? ? ? ? ? ? ?? ? ? ? ? ?// 第五步,寫入實(shí)體數(shù)據(jù) 實(shí)際應(yīng)用中這些數(shù)據(jù)從數(shù)據(jù)庫得到 ?? ??? ??? ?row = sheet.createRow(1); ?? ??? ??? ?row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(1); ? ?? ??? ??? ?row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(2);? ?? ??? ??? ?row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(3); ? //商品價格 ?? ??? ??? ?row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(4); ?//規(guī)格 ? ? ? ?? ?? ??? ??? ?// 第六步,將文件存到指定位置 ? ?? ? ? ? ? ?try ? ?? ? ? ? ? ?{ ? ?? ? ? ? ? ??? ?OutputStream out = response.getOutputStream(); ?? ? ? ? ? ??? ?workbook.write(out); ?? ? ? ? ? ? ? ?out.close(); ? ?? ? ? ? ? ?} ? ?? ? ? ? ? ?catch (Exception e) ? ?? ? ? ? ? ?{ ? ?? ? ? ? ? ? ? ?e.printStackTrace(); ? ?? ? ? ? ? ?} ? ?? ??? ?} catch (Exception e) { ?? ??? ??? ?e.printStackTrace(); ?? ??? ?}*/ ? ? }
模板位置:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用FeignClient調(diào)用遠(yuǎn)程服務(wù)時整合本地的實(shí)現(xiàn)方法
這篇文章主要介紹了使用FeignClient調(diào)用遠(yuǎn)程服務(wù)時整合本地的實(shí)現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03java網(wǎng)絡(luò)爬蟲連接超時解決實(shí)例代碼
這篇文章主要介紹了java網(wǎng)絡(luò)爬蟲連接超時解決的問題,分享了一則使用httpclient解決連接超時的Java爬蟲實(shí)例代碼,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下2018-01-01SpringBoot實(shí)現(xiàn)HTTP調(diào)用的七種方式總結(jié)
小編在工作中,遇到一些需要調(diào)用三方接口的任務(wù),就需要用到 HTTP 調(diào)用工具,這里,我總結(jié)了一下 實(shí)現(xiàn) HTTP 調(diào)用的方式,共有 7 種(后續(xù)會繼續(xù)新增),需要的朋友可以參考下2023-09-09Spring boot @ModelAttribute標(biāo)注的實(shí)現(xiàn)
這篇文章主要介紹了Spring boot @ModelAttribute標(biāo)注的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01java從命令行獲取數(shù)據(jù)的三種方式代碼實(shí)例
這篇文章主要介紹了java從命令行獲取數(shù)據(jù)的三種方式代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12IDEA啟動Springboot報(bào)錯:無效的目標(biāo)發(fā)行版:17 的解決辦法
這篇文章主要給大家介紹了IDEA啟動Springboot報(bào)錯:無效的目標(biāo)發(fā)行版:17 的解決辦法,文中通過代碼示例和圖文講解的非常詳細(xì),對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下2024-02-02Java C++解決在排序數(shù)組中查找數(shù)字出現(xiàn)次數(shù)問題
本文終于介紹了分別通過Java和C++實(shí)現(xiàn)統(tǒng)計(jì)一個數(shù)字在排序數(shù)組中出現(xiàn)的次數(shù)。文中詳細(xì)介紹了實(shí)現(xiàn)思路,感興趣的小伙伴可以跟隨小編學(xué)習(xí)一下2021-12-12使用Mybatis Plus整合多數(shù)據(jù)源和讀寫分離的詳細(xì)過程
這篇文章主要介紹了Mybatis Plus整合多數(shù)據(jù)源和讀寫分離的詳細(xì)過程,mybatisplus可以整合阿里的分布式事務(wù)組件seata,本文通過示例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-09-09