java如何對接企業(yè)微信的實現(xiàn)步驟
前言
最近實現(xiàn)社群對接企業(yè)微信,對接的過程遇到一些點,在此記錄。
企業(yè)微信介紹
企業(yè)微信具有和微信一樣的體驗,用于企業(yè)內(nèi)部成員和外部客戶的管理,可以由此構(gòu)建出社群生態(tài)。
企業(yè)微信提供了豐富的api進(jìn)行調(diào)用獲取數(shù)據(jù)管理,也提供了各種回調(diào)事件,當(dāng)數(shù)據(jù)發(fā)生變化時,可以及時知道。
我們分為兩部分進(jìn)行講解,第一部分調(diào)用企業(yè)微信api,第二部分,接收企業(yè)微信的回調(diào)。
調(diào)用企業(yè)微信api
api的開發(fā)文檔地址:https://work.weixin.qq.com/api/doc/90000/90135/90664
調(diào)用企業(yè)微信所必須的東西就是企業(yè)的accesstoken。獲取accesstoken則需要我們的corpid和corpsercret。
具體我們可以參照這里https://work.weixin.qq.com/api/doc/90000/90135/91039
有了token之后,我們就可以通過http請求來調(diào)用各種api,獲取數(shù)據(jù)。舉一個例子,創(chuàng)建成員的api,如下,我們只要使用http工具調(diào)用即可。
這里分享一個http調(diào)用工具。
@Slf4j public class HttpUtils { static CloseableHttpClient httpClient; private HttpUtils() { throw new IllegalStateException("Utility class"); } static { Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()) .register("https", SSLConnectionSocketFactory.getSocketFactory()) .build(); PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry); connectionManager.setMaxTotal(200); connectionManager.setDefaultMaxPerRoute(200); connectionManager.setDefaultSocketConfig( SocketConfig.custom().setSoTimeout(15, TimeUnit.SECONDS) .setTcpNoDelay(true).build() ); connectionManager.setValidateAfterInactivity(TimeValue.ofSeconds(15)); httpClient = HttpClients.custom() .setConnectionManager(connectionManager) .disableAutomaticRetries() .build(); } public static String get(String url, Map<String, Object> paramMap, Map<String, String> headerMap) { String param = paramMap.entrySet().stream().map(n -> n.getKey() + "=" + n.getValue()).collect(Collectors.joining("&")); String fullUrl = url + "?" + param; final HttpGet httpGet = new HttpGet(fullUrl); if (Objects.nonNull(headerMap) && headerMap.size() > 0) { headerMap.forEach((key, value) -> httpGet.addHeader(key, value)); } CloseableHttpResponse response = null; try { response = httpClient.execute(httpGet); String strResult = EntityUtils.toString(response.getEntity()); if (200 != response.getCode()) { log.error("HTTP get 返回狀態(tài)非200[resp={}]", strResult); } return strResult; } catch (IOException | ParseException e) { log.error("HTTP get 異常", e); return ""; } finally { if (null != response) { try { EntityUtils.consume(response.getEntity()); } catch (IOException e) { e.printStackTrace(); } } } } public static String post(String url,Map<String, Object> paramMap, Map<String, String> headerMap, String data) { CloseableHttpResponse response = null; try { String param = paramMap.entrySet().stream().map(n -> n.getKey() + "=" + n.getValue()).collect(Collectors.joining("&")); String fullUrl = url + "?" + param; final HttpPost httpPost = new HttpPost(fullUrl); if (Objects.nonNull(headerMap) && headerMap.size() > 0) { headerMap.forEach((key, value) -> httpPost.addHeader(key, value)); } StringEntity httpEntity = new StringEntity(data, StandardCharsets.UTF_8); httpPost.setEntity(httpEntity); response = httpClient.execute(httpPost); if (200 == response.getCode()) { String strResult = EntityUtils.toString(response.getEntity()); return strResult; } } catch (IOException | ParseException e) { e.printStackTrace(); return ""; } finally { if (null != response) { try { EntityUtils.consume(response.getEntity()); } catch (IOException e) { e.printStackTrace(); } } } return ""; } }
對接企業(yè)微信的回調(diào)
回調(diào)分為很多種,比如通訊錄的回調(diào)如下:
https://work.weixin.qq.com/api/doc/90000/90135/90967
整體的回調(diào)流程如下:
配置回調(diào)服務(wù),需要有三個配置項,分別是:URL, Token, EncodingAESKey。
首先,URL為回調(diào)服務(wù)地址,由開發(fā)者搭建,用于接收通知消息或者事件。
其次,Token用于計算簽名,由英文或數(shù)字組成且長度不超過32位的自定義字符串。開發(fā)者提供的URL是公開可訪問的,這就意味著拿到這個URL,就可以往該鏈接推送消息。那么URL服務(wù)需要解決兩個問題:
如何分辨出是否為企業(yè)微信來源
如何分辨出推送消息的內(nèi)容是否被篡改
通過數(shù)字簽名就可以解決上述的問題。具體為:約定Token作為密鑰,僅開發(fā)者和企業(yè)微信知道,在傳輸中不可見,用于參與簽名計算。企業(yè)微信在推送消息時,將消息內(nèi)容與Token計算出簽名。開發(fā)者接收到推送消息時,也按相同算法計算出簽名。如果為同一簽名,則可信任來源為企業(yè)微信,并且內(nèi)容是完整的。
如果非企業(yè)微信來源,由于攻擊者沒有正確的Token,無法算出正確的簽名;
如果消息內(nèi)容被篡改,由于開發(fā)者會將接收的消息內(nèi)容與Token重算一次簽名,該值與參數(shù)的簽名不一致,則會拒絕該請求。
最后,EncodingAESKey用于消息內(nèi)容加密,由英文或數(shù)字組成且長度為43位的自定義字符串。由于消息是在公開的因特網(wǎng)上傳輸,消息內(nèi)容是可被截獲的,如果內(nèi)容未加密,則截獲者可以直接閱讀消息內(nèi)容。若消息內(nèi)容包含一些敏感信息,就非常危險了。EncodingAESKey就是在這個背景基礎(chǔ)上提出,將發(fā)送的內(nèi)容進(jìn)行加密,并組裝成一定格式后再發(fā)送。
對接回調(diào),我們就要實現(xiàn)上述的加密,篡改等代碼。這里分享java版本的實現(xiàn)。
AesException
public class AesException extends Exception { public final static int OK = 0; public final static int ValidateSignatureError = -40001; public final static int ParseXmlError = -40002; public final static int ComputeSignatureError = -40003; public final static int IllegalAesKey = -40004; public final static int ValidateCorpidError = -40005; public final static int EncryptAESError = -40006; public final static int DecryptAESError = -40007; public final static int IllegalBuffer = -40008; private int code; private static String getMessage(int code) { switch (code) { case ValidateSignatureError: return "簽名驗證錯誤"; case ParseXmlError: return "xml解析失敗"; case ComputeSignatureError: return "sha加密生成簽名失敗"; case IllegalAesKey: return "SymmetricKey非法"; case ValidateCorpidError: return "corpid校驗失敗"; case EncryptAESError: return "aes加密失敗"; case DecryptAESError: return "aes解密失敗"; case IllegalBuffer: return "解密后得到的buffer非法"; default: return null; } } public int getCode() { return code; } AesException(int code) { super(getMessage(code)); this.code = code; } }
MessageUtil
public class MessageUtil { /** * 解析微信發(fā)來的請求(XML). * * @param msg 消息 * @return map */ public static Map<String, String> parseXml(final String msg) { // 將解析結(jié)果存儲在HashMap中 Map<String, String> map = new HashMap<String, String>(); // 從request中取得輸入流 try (InputStream inputStream = new ByteArrayInputStream(msg.getBytes(StandardCharsets.UTF_8.name()))) { // 讀取輸入流 SAXReader reader = new SAXReader(); Document document = reader.read(inputStream); // 得到xml根元素 Element root = document.getRootElement(); // 得到根元素的所有子節(jié)點 List<Element> elementList = root.elements(); // 遍歷所有子節(jié)點 for (Element e : elementList) { map.put(e.getName(), e.getText()); } } catch (Exception e) { e.printStackTrace(); } return map; } }
public enum QywechatEnum { TEST("測試", "123123123123", "123123123123", "12312312312"); /** * 應(yīng)用名 */ private String name; /** * 企業(yè)ID */ private String corpid; /** * 回調(diào)url配置的token */ private String token; /** * 隨機(jī)加密串 */ private String encodingAESKey; QywechatEnum(final String name, final String corpid, final String token, final String encodingAESKey) { this.name = name; this.corpid = corpid; this.encodingAESKey = encodingAESKey; this.token = token; } public String getCorpid() { return corpid; } public String getName() { return name; } public String getToken() { return token; } public String getEncodingAESKey() { return encodingAESKey; } }
public class QywechatInfo { /** * 簽名 */ private String msgSignature; /** * 隨機(jī)時間戳 */ private String timestamp; /** * 隨機(jī)值 */ private String nonce; /** * 加密的xml字符串 */ private String sPostData; /** * 企業(yè)微信回調(diào)配置 */ private QywechatEnum qywechatEnum; }
public class SHA1Utils { /** * 用SHA1算法生成安全簽名 * * @param token 票據(jù) * @param timestamp 時間戳 * @param nonce 隨機(jī)字符串 * @param encrypt 密文 * @return 安全簽名 * @throws AesException */ public static String getSHA1(String token, String timestamp, String nonce, String encrypt) throws AesException { try { String[] array = new String[]{token, timestamp, nonce, encrypt}; StringBuffer sb = new StringBuffer(); // 字符串排序 Arrays.sort(array); for (int i = 0; i < 4; i++) { sb.append(array[i]); } String str = sb.toString(); // SHA1簽名生成 MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(str.getBytes()); byte[] digest = md.digest(); StringBuffer hexstr = new StringBuffer(); String shaHex = ""; for (int i = 0; i < digest.length; i++) { shaHex = Integer.toHexString(digest[i] & 0xFF); if (shaHex.length() < 2) { hexstr.append(0); } hexstr.append(shaHex); } return hexstr.toString(); } catch (Exception e) { e.printStackTrace(); throw new AesException(AesException.ComputeSignatureError); } } }
public class WXBizMsgCrypt { static Charset CHARSET = Charset.forName("utf-8"); Base64 base64 = new Base64(); byte[] aesKey; String token; String receiveid; /** * 構(gòu)造函數(shù) * * @throws AesException 執(zhí)行失敗,請查看該異常的錯誤碼和具體的錯誤信息 */ public WXBizMsgCrypt(final QywechatEnum qywechatEnum) throws AesException { this.token = qywechatEnum.getToken(); this.receiveid = qywechatEnum.getCorpid(); String encodingAesKey = qywechatEnum.getEncodingAESKey(); if (encodingAesKey.length() != 43) { throw new AesException(AesException.IllegalAesKey); } aesKey = Base64.decodeBase64(encodingAesKey + "="); } // 生成4個字節(jié)的網(wǎng)絡(luò)字節(jié)序 byte[] getNetworkBytesOrder(int sourceNumber) { byte[] orderBytes = new byte[4]; orderBytes[3] = (byte) (sourceNumber & 0xFF); orderBytes[2] = (byte) (sourceNumber >> 8 & 0xFF); orderBytes[1] = (byte) (sourceNumber >> 16 & 0xFF); orderBytes[0] = (byte) (sourceNumber >> 24 & 0xFF); return orderBytes; } // 還原4個字節(jié)的網(wǎng)絡(luò)字節(jié)序 int recoverNetworkBytesOrder(byte[] orderBytes) { int sourceNumber = 0; for (int i = 0; i < 4; i++) { sourceNumber <<= 8; sourceNumber |= orderBytes[i] & 0xff; } return sourceNumber; } // 隨機(jī)生成16位字符串 String getRandomStr() { String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; Random random = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < 16; i++) { int number = random.nextInt(base.length()); sb.append(base.charAt(number)); } return sb.toString(); } /** * 對明文進(jìn)行加密. * * @param text 需要加密的明文 * @return 加密后base64編碼的字符串 * @throws AesException aes加密失敗 */ String encrypt(String randomStr, String text) throws AesException { ByteGroup byteCollector = new ByteGroup(); byte[] randomStrBytes = randomStr.getBytes(CHARSET); byte[] textBytes = text.getBytes(CHARSET); byte[] networkBytesOrder = getNetworkBytesOrder(textBytes.length); byte[] receiveidBytes = receiveid.getBytes(CHARSET); // randomStr + networkBytesOrder + text + receiveid byteCollector.addBytes(randomStrBytes); byteCollector.addBytes(networkBytesOrder); byteCollector.addBytes(textBytes); byteCollector.addBytes(receiveidBytes); // ... + pad: 使用自定義的填充方式對明文進(jìn)行補(bǔ)位填充 byte[] padBytes = PKCS7Encoder.encode(byteCollector.size()); byteCollector.addBytes(padBytes); // 獲得最終的字節(jié)流, 未加密 byte[] unencrypted = byteCollector.toBytes(); try { // 設(shè)置加密模式為AES的CBC模式 Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); SecretKeySpec keySpec = new SecretKeySpec(aesKey, "AES"); IvParameterSpec iv = new IvParameterSpec(aesKey, 0, 16); cipher.init(Cipher.ENCRYPT_MODE, keySpec, iv); // 加密 byte[] encrypted = cipher.doFinal(unencrypted); // 使用BASE64對加密后的字符串進(jìn)行編碼 String base64Encrypted = base64.encodeToString(encrypted); return base64Encrypted; } catch (Exception e) { e.printStackTrace(); throw new AesException(AesException.EncryptAESError); } } /** * 對密文進(jìn)行解密. * * @param text 需要解密的密文 * @return 解密得到的明文 * @throws AesException aes解密失敗 */ String decrypt(String text) throws AesException { byte[] original; try { // 設(shè)置解密模式為AES的CBC模式 Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding"); SecretKeySpec key_spec = new SecretKeySpec(aesKey, "AES"); IvParameterSpec iv = new IvParameterSpec(Arrays.copyOfRange(aesKey, 0, 16)); cipher.init(Cipher.DECRYPT_MODE, key_spec, iv); // 使用BASE64對密文進(jìn)行解碼 byte[] encrypted = Base64.decodeBase64(text); // 解密 original = cipher.doFinal(encrypted); } catch (Exception e) { e.printStackTrace(); throw new AesException(AesException.DecryptAESError); } String xmlContent, from_receiveid; try { // 去除補(bǔ)位字符 byte[] bytes = PKCS7Encoder.decode(original); // 分離16位隨機(jī)字符串,網(wǎng)絡(luò)字節(jié)序和receiveid byte[] networkOrder = Arrays.copyOfRange(bytes, 16, 20); int xmlLength = recoverNetworkBytesOrder(networkOrder); xmlContent = new String(Arrays.copyOfRange(bytes, 20, 20 + xmlLength), CHARSET); from_receiveid = new String(Arrays.copyOfRange(bytes, 20 + xmlLength, bytes.length), CHARSET); } catch (Exception e) { e.printStackTrace(); throw new AesException(AesException.IllegalBuffer); } // receiveid不相同的情況 if (!from_receiveid.equals(receiveid)) { throw new AesException(AesException.ValidateCorpidError); } return xmlContent; } /** * 將企業(yè)微信回復(fù)用戶的消息加密打包. * <ol> * <li>對要發(fā)送的消息進(jìn)行AES-CBC加密</li> * <li>生成安全簽名</li> * <li>將消息密文和安全簽名打包成xml格式</li> * </ol> * * @param replyMsg 企業(yè)微信待回復(fù)用戶的消息,xml格式的字符串 * @param timeStamp 時間戳,可以自己生成,也可以用URL參數(shù)的timestamp * @param nonce 隨機(jī)串,可以自己生成,也可以用URL參數(shù)的nonce * * @return 加密后的可以直接回復(fù)用戶的密文,包括msg_signature, timestamp, nonce, encrypt的xml格式的字符串 * @throws AesException 執(zhí)行失敗,請查看該異常的錯誤碼和具體的錯誤信息 */ public String EncryptMsg(String replyMsg, String timeStamp, String nonce) throws AesException { // 加密 String encrypt = encrypt(getRandomStr(), replyMsg); // 生成安全簽名 if (timeStamp == "") { timeStamp = Long.toString(System.currentTimeMillis()); } String signature = SHA1Utils.getSHA1(token, timeStamp, nonce, encrypt); // System.out.println("發(fā)送給平臺的簽名是: " + signature[1].toString()); // 生成發(fā)送的xml String result = XMLParse.generate(encrypt, signature, timeStamp, nonce); return result; } /** * 檢驗消息的真實性,并且獲取解密后的明文. * <ol> * <li>利用收到的密文生成安全簽名,進(jìn)行簽名驗證</li> * <li>若驗證通過,則提取xml中的加密消息</li> * <li>對消息進(jìn)行解密</li> * </ol> * * @param qywechatInfo bean * @return 解密后的原文 * @throws AesException 執(zhí)行失敗,請查看該異常的錯誤碼和具體的錯誤信息 */ public String decryptMsg(final QywechatInfo qywechatInfo) throws AesException { // 密鑰,公眾賬號的app secret // 提取密文 Object[] encrypt = XMLParse.extract(qywechatInfo.getSPostData()); /** * @param msgSignature 簽名串,對應(yīng)URL參數(shù)的msg_signature * @param timeStamp 時間戳,對應(yīng)URL參數(shù)的timestamp * @param nonce 隨機(jī)串,對應(yīng)URL參數(shù)的nonce * @param postData 密文,對應(yīng)POST請求的數(shù)據(jù) */ // 驗證安全簽名 String signature = SHA1Utils.getSHA1(token, qywechatInfo.getTimestamp(), qywechatInfo.getNonce(), encrypt[1].toString()); // 和URL中的簽名比較是否相等 // System.out.println("第三方收到URL中的簽名:" + msg_sign); // System.out.println("第三方校驗簽名:" + signature); if (!signature.equals(qywechatInfo.getMsgSignature())) { throw new AesException(AesException.ValidateSignatureError); } // 解密 String result = decrypt(encrypt[1].toString()); return result; } /** * 驗證URL * @param msgSignature 簽名串,對應(yīng)URL參數(shù)的msg_signature * @param timeStamp 時間戳,對應(yīng)URL參數(shù)的timestamp * @param nonce 隨機(jī)串,對應(yīng)URL參數(shù)的nonce * @param echoStr 隨機(jī)串,對應(yīng)URL參數(shù)的echostr * * @return 解密之后的echostr * @throws AesException 執(zhí)行失敗,請查看該異常的錯誤碼和具體的錯誤信息 */ public String verifyURL(String msgSignature, String timeStamp, String nonce, String echoStr) throws AesException { String signature = SHA1Utils.getSHA1(token, timeStamp, nonce, echoStr); if (!signature.equals(msgSignature)) { throw new AesException(AesException.ValidateSignatureError); } String result = decrypt(echoStr); return result; } static class ByteGroup { ArrayList<Byte> byteContainer = new ArrayList<Byte>(); public byte[] toBytes() { byte[] bytes = new byte[byteContainer.size()]; for (int i = 0; i < byteContainer.size(); i++) { bytes[i] = byteContainer.get(i); } return bytes; } public ByteGroup addBytes(byte[] bytes) { for (byte b : bytes) { byteContainer.add(b); } return this; } public int size() { return byteContainer.size(); } } static class PKCS7Encoder { static Charset CHARSET = Charset.forName("utf-8"); static int BLOCK_SIZE = 32; /** * 獲得對明文進(jìn)行補(bǔ)位填充的字節(jié). * * @param count 需要進(jìn)行填充補(bǔ)位操作的明文字節(jié)個數(shù) * @return 補(bǔ)齊用的字節(jié)數(shù)組 */ static byte[] encode(int count) { // 計算需要填充的位數(shù) int amountToPad = BLOCK_SIZE - (count % BLOCK_SIZE); if (amountToPad == 0) { amountToPad = BLOCK_SIZE; } // 獲得補(bǔ)位所用的字符 char padChr = chr(amountToPad); String tmp = new String(); for (int index = 0; index < amountToPad; index++) { tmp += padChr; } return tmp.getBytes(CHARSET); } /** * 刪除解密后明文的補(bǔ)位字符 * * @param decrypted 解密后的明文 * @return 刪除補(bǔ)位字符后的明文 */ static byte[] decode(byte[] decrypted) { int pad = (int) decrypted[decrypted.length - 1]; if (pad < 1 || pad > 32) { pad = 0; } return Arrays.copyOfRange(decrypted, 0, decrypted.length - pad); } /** * 將數(shù)字轉(zhuǎn)化成ASCII碼對應(yīng)的字符,用于對明文進(jìn)行補(bǔ)碼 * * @param a 需要轉(zhuǎn)化的數(shù)字 * @return 轉(zhuǎn)化得到的字符 */ static char chr(int a) { byte target = (byte) (a & 0xFF); return (char) target; } } }
如上代碼拷貝好后,我們便可以在企業(yè)微信的回調(diào)事件配置界面,增加回調(diào)的連接地址。
實現(xiàn)方案過程中遇到的點
1、回調(diào)配置的地址只支持一個,所以要把回調(diào)服務(wù)抽取出來,申請公網(wǎng)域名。要注意將接收到的回調(diào)消息放到消息隊列,供其他所有服務(wù)接收處理。
2、處理回調(diào)要注意逆序問題,假如更新操作先來了,新增操作還沒有開始。
3、可以采用消息補(bǔ)償,定時任務(wù)刷新機(jī)制,手動同步機(jī)制,保證數(shù)據(jù)的一致性。
4、要實現(xiàn)重試機(jī)制,因為可能觸發(fā)微信的并發(fā)調(diào)用限制。
到此這篇關(guān)于java如何對接企業(yè)微信的實現(xiàn)步驟的文章就介紹到這了,更多相關(guān)java對接企業(yè)微信內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Java?3年面試經(jīng)驗告訴你Mybatis是如何進(jìn)行分頁的
這篇文章主要介紹了Java?3年面試經(jīng)驗告訴你Mybatis是如何進(jìn)行分頁的,對于任何ORM框架,分頁的實現(xiàn)邏輯無外乎兩種,不管怎么包裝,最終給到開發(fā)者的,只是使用上的差異而已,本文給大家講解的很明白,感興趣的朋友一起看看吧2022-09-09Java?超詳細(xì)講解Spring?MVC異常處理機(jī)制
Spring?MVC中提供了一個通用的異常處理機(jī)制,它提供了一個成熟、簡潔并且清晰的異常處理方案。當(dāng)使用Spring?MVC開發(fā)Web應(yīng)用時,利用這套現(xiàn)成的機(jī)制進(jìn)行異常處理也更加自然并且高效2022-04-04java進(jìn)行遠(yuǎn)程部署與調(diào)試及原理詳解
這篇文章主要介紹了java進(jìn)行遠(yuǎn)程部署與調(diào)試及原理詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-12-12SpringMVC攔截器創(chuàng)建配置及執(zhí)行順序
這篇文章主要為大家介紹了SpringMVC攔截器創(chuàng)建配置及執(zhí)行順序,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05System.currentTimeMillis()計算方式與時間的單位轉(zhuǎn)換詳解
這篇文章主要介紹了System.currentTimeMillis()計算方式與時間的單位轉(zhuǎn)換詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05在SpringBoot項目中實現(xiàn)讀寫分離的流程步驟
SpringBoot作為一種快速開發(fā)框架,廣泛應(yīng)用于Java項目中,在一些大型應(yīng)用中,數(shù)據(jù)庫的讀寫分離是提升性能和擴(kuò)展性的一種重要手段,本文將介紹如何在SpringBoot項目中優(yōu)雅地實現(xiàn)讀寫分離,并通過適當(dāng)?shù)拇a插入,詳細(xì)展開實現(xiàn)步驟,同時進(jìn)行拓展和分析2023-11-11