MyBatis 實踐 -配置

MyBatis 實踐

標簽: Java與存儲


Configuration

mybatis-configuration.xml是MyBatis的全局配置文件(文件名稱隨意),其配置內容和順序例如以下:

  1. properties : 屬性(文件)載入/配置
  2. settings : 全局配置參數
  3. typeAliases : 定義類型別名
  4. typeHandlers : 類型處理器
  5. objectFactory : 對象工廠
  6. plugins : 插件
  7. environments : 環境集合屬性對象
    • environment
      • transactionManager : 事務管理
      • dataSource : 數據源
  8. databaseIdProvider:P數據庫廠商標識
  9. mappers : 映射器

properties

方便對配置參數統一管理,供其它XML引用,我們能夠將數據庫的連接參數抽取出來:

  • db.properties
## Data Source
mysql.driver.class=com.mysql.jdbc.Driver
mysql.url=jdbc:mysql://host:port/db?characterEncoding=utf-8
mysql.user=user
mysql.password=password
  • mybatis-configuration.xml
<properties resource="db.properties"/><environments default="development"><environment id="development"><!-- 配置JDBC事務管理--><transactionManager type="JDBC"/><!-- 配置數據源--><dataSource type="POOLED"><property name="driver" value="${mysql.driver.class}"/><property name="url" value="${mysql.url}"/><property name="username" value="${mysql.user}"/><property name="password" value="${mysql.password}"/></dataSource></environment>
</environments>

注: MyBatis依照例如以下順序載入properties:
1) 在<properties>標簽內定義的屬性;
2) .properties文件里定義的屬性;
3) 最后讀取作為方法參數傳遞的屬性.


settings

MyBatis全局配置參數,會影響MyBatis執行時行為(如:開啟二級緩存/延遲載入).見MyBatis文檔.


typeAliases

MyBatis默認支持的類型別名可參考MyBatis文檔,我們也能夠自己定義別名,但并不推薦,使用PO對象的全限定名能夠提高Statement的可讀性.


typeHandlers

typeHandlers用于Java類型和JDBC類型轉換,MyBatis提供了非常多默認的類型處理器(詳見MyBatis文檔),并且也基本滿足日常開發需求,因此一般就不再須要單獨定義.


mappers

前面已經將SQL語句定義到了mapper文件里,那么<mappers/>屬性就是告訴MyBatis到哪里去尋找mapper文件,MyBatis提供了例如以下幾種配置方法:

配置描寫敘述
<mapper resource=""/>使用類路徑的資源(Resources/java文件夾下)
<mapper url=""/>使用全然限定路徑
<mapper class=""/>使用mapper接口類路徑
<package name=""/>注冊指定包下的全部mapper接口

注意:后兩種方式要求mapper接口名和mapper映射文件名稱稱同樣,且放在同一個文件夾中(不推薦).

其它關于MyBatis的配置信息可參考MyBatis文檔.


整合Spring

實現MyBatis與Spring整合之后,能夠使用Spring來管理SqlSessionFactory和mapper接口,Spring自己主動使用SqlSessionFactory創建SqlSession,并將實現好DAO接口注冊到Spring容器中, 供@Autowired使用.


1. 加入依賴

  • 加入Spring支持
<dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-expression</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-aop</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId><version>${spring.version}</version>
</dependency>
<dependency><groupId>org.springframework</groupId><artifactId>spring-tx</artifactId><version>${spring.version}</version>
</dependency>
  • 加入MyBatis-Spring包
<dependency><groupId>org.mybatis</groupId><artifactId>mybatis-spring</artifactId><version>${mybatis-spring.version}</version>
</dependency>
  • 加入Hikaricp數據庫連接池
<dependency><groupId>com.zaxxer</groupId><artifactId>HikariCP</artifactId><version>${hikaricp.version}</version>
</dependency>
  • 不要忘了MySQL數據庫驅動
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>${mysql.version}</version>
</dependency>

2. 配置文件

  • 精簡mybatis-configuration.xml
    能夠將數據源的配置移到以下的applicationContext-datasource.xml中.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><mappers><mapper resource="mybatis/mapper/UserDAO.xml"/></mappers>
</configuration>
  • 定義applicationContext-datasource.xml
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><context:property-placeholder location="classpath:db.properties"/><!-- 配置數據源 --><bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig"><property name="driverClassName" value="${mysql.driver.class}"/><property name="jdbcUrl" value="${mysql.url}"/><property name="username" value="${mysql.user}"/><property name="password" value="${mysql.password}"/><property name="maximumPoolSize" value="5"/><property name="maxLifetime" value="700000"/><property name="idleTimeout" value="600000"/><property name="connectionTimeout" value="10000"/><property name="dataSourceProperties"><props><prop key="dataSourceClassName">com.mysql.jdbc.jdbc2.optional.MysqlDataSource</prop><prop key="cachePrepStmts">true</prop><prop key="prepStmtCacheSize">250</prop><prop key="prepStmtCacheSqlLimit">2048</prop></props></property></bean><bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"><constructor-arg ref="hikariConfig"/></bean><!-- 配置SqlSessionFactory --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="classpath:mybatis/mybatis-configuration.xml"/></bean><!-- 依據mapper接口生成代理對象 --><bean id="dao" class="org.mybatis.spring.mapper.MapperFactoryBean"><property name="mapperInterface" value="com.fq.mybatis.UserDAO"/><property name="sqlSessionFactory" ref="sqlSessionFactory"/></bean>
</beans>

上面的配置存在一個問題:須要針對每一個mapper配置一個MapperFactoryBean(繁瑣),因此這段依據mapper接口生成代理對象的配置可更改例如以下:

<!-- 基于包掃描的mapper配置 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="basePackage" value="com.fq.mybatis"/><property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>

附: applicationContext-database.xml完整配置可參考: Git地址

  • 定義Spring主配置文件applicationContext.xml
    定義注解驅動載入靜態配置文件datasource:
<?

xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 注解驅動 --> <context:annotation-config/> <!-- 載入靜態配置文件 --> <import resource="applicationContext-datasource.xml"/> </beans>
  • Client
/*** @author jifang* @since 16/2/22 上午10:20.*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring/applicationContext.xml")
public class UserDAOClient {@Autowiredprivate UserDAO dao;@Testpublic void client() throws Exception {User user = dao.selectUserById(1);System.out.println(user);}
}

緩存

與大多數持久層框架一樣,MyBatis也支持一級緩存二級緩存.

緩存作用是提升系統總體性能(不是提升數據庫性能:由于緩存將數據庫中的數據存放到內存,下次查詢同樣內容時直接從內存讀取,減輕數據庫壓力,并且直接從內存中讀取數據要比從數據庫檢索快非常多,因此能夠提升系統總體性能).

緩存數據更新:當一個作用域(一級緩存為SqlSession/二級緩存為namespace)進行了C/U/D操作后,默認該作用域下全部緩存都被清空.


一級緩存

MyBatis默認開啟了一級緩存.一級緩存是基于org.apache.ibatis.cache.impl.PerpetualCacheHashMap本地緩存,其存儲作用域為SqlSession,同一個SqlSession幾次執行同樣SQL,后面的查詢會直接從緩存中載入,從而提高查詢效率/減輕數據庫壓力.當SqlSessionflush/close后,該SqlSession中的全部Cache數據被清空.


二級緩存

與一級緩存機制相似,MyBatis二級緩存默認也是採用PerpetualCacheHashMap存儲,不同在于二級緩存存儲作用域為namespace/mapper,并且能夠自己定義緩存實現,如Ehcache.

MyBatis默認沒有開啟二級緩存,須要經過以下步驟才干使用:

  • 啟用二級緩存(可選)
    其須要在mybatis-configuration.xml的settings全局參數中開啟:
<settings><setting name="cacheEnabled" value="true"/>
</settings>

cacheEnabled對此配置文件下的全部cache進行全局性開/關設置(默覺得true).

  • 配置緩存策略
    在mapper映射文件里加入<cache/>標簽,以指定該namespace開啟二級緩存, 并指定緩存策略:
<cache eviction="LRU" flushInterval="60000" size="512" readOnly="true"/>

1) eviction:緩存淘汰算法:

算法描寫敘述釋義
LRU近期最少使用移除最長時間不被使用的對象(默認).
FIFO先進先出按對象進入緩存的順序移除.
SOFT軟引用移除基于垃圾回收器狀態和軟引用規則的對象.
WEAK弱引用更積極地移除基于垃圾收集器狀態和弱引用規則的對象.

2) flushInterval:刷新間隔(緩存過期時間),單位為毫秒,MyBatis會每隔一段時間自己主動清空緩存(默認刷新間隔為空, 即永只是期,僅調用語句時刷新).
3) size:引用數目,要記住你緩存的對象的數目和執行環境可用內存資源數目(默認1024).
4) readOnly: 僅僅讀.假設為true,則全部同樣SQL返回同一對象(因此這些對象不能改動,有助于提高性能,但并發操作同一條數據時,可能不安全);假設為false,則同樣SQL后面返回的是cache的clone副本(通過序列化,慢一些但更是安全,因此默認是false).

  • 序列化
    PO對象要實現Serializable序列化,由于二級緩存的存儲介質不一定僅僅是內存:
public class User implements Serializable {//...
}
  • Client
@Test
public void cacheClient() throws Exception {testCache(factory.openSession());testCache(factory.openSession());testCache(factory.openSession());
}private void testCache(SqlSession session) throws Exception {UserDAO dao = session.getMapper(UserDAO.class);dao.selectUserById(1);// 須要將SqlSession關閉才干將數據寫入緩存.session.close();
}

執行代碼, 并觀察log輸出的命中率(Cache Hit Ratio).

  • Statement配置

1) 禁用緩存: 在Statement中設置useCache="false"能夠禁用當前select語句的二級緩存(默覺得true:該SQL啟用二級緩存).

<select id="selectUserById" parameterType="java.lang.Integer" resultType="com.fq.domain.User" useCache="true">SELECT *FROM userWHERE id = #{id};
</select>

2)刷新緩存: 同一個namespace中,假設還有其它insert/update/delete操作,須要刷新緩存,使用flushCache="true"屬性設置(默覺得true刷新緩存).

<insert id="insertUserList" parameterType="java.util.List" flushCache="true">INSERT INTO user(name, password) VALUES<if test="list != null and list.size != 0"><foreach collection="list" item="user" separator=",">(#{user.name}, #{user.password})</foreach></if>
</insert>

整合Ehcache

MyBatis暴露一個org.apache.ibatis.cache.Cache接口出來,通過實現該接口,能夠實現各類緩存產品(如Ehcache/Redis/Memcached)與MyBatis的整合(MyBatis的特長操作數據庫,緩存管理并非其擅長,因此整合其它緩存產品能夠提高系統總體性能).
Ehcache是一個純Java開發的進程內緩存框架,具有開源/高速/靈活等特點,是Hibernate默認的CacheProvider.使用Ehcache須要在pom.xml中加入例如以下依賴:

<dependency><groupId>net.sf.ehcache</groupId><artifactId>ehcache-core</artifactId><version>2.6.11</version>
</dependency>
<dependency><groupId>org.mybatis.caches</groupId><artifactId>mybatis-ehcache</artifactId><version>1.0.3</version>
</dependency>
  • 配置Ehcache
    在Resources文件夾下加入ehcache.xml配置文件
<ehcache><diskStore path="/data/cache"/><defaultCache
            maxElementsInMemory="1000"maxElementsOnDisk="10000000"eternal="false"overflowToDisk="false"timeToIdleSeconds="120"timeToLiveSeconds="120"diskExpiryThreadIntervalSeconds="120"memoryStoreEvictionPolicy="LRU"></defaultCache>
</ehcache>
屬性描寫敘述
diskStore指定緩存數據在磁盤的存儲位置
maxElementsInMemory在內存中緩存element的最大數目
maxElementsOnDisk在磁盤上緩存element的最大數目,0表示無窮大
eternal設定緩存的elements是否永遠只是期.true,則緩存的數據始終有效,假設為false那么還要依據timeToIdleSeconds,timeToLiveSeconds推斷
overflowToDisk設定當內存緩存溢出的時候是否將過期的element緩存到磁盤上
timeToIdleSeconds刷新間隔:緩存數據前后兩次訪問時間超過timeToIdleSeconds時,這些數據便會刪除(默覺得0,時間間隔無窮大)
timeToLiveSeconds緩存element的有效生命期(默覺得0,時間無限)
diskSpoolBufferSizeMB設置DiskStore(磁盤緩存)緩存區大小.默認是30MB.
diskPersistent在JVM重新啟動時是否使用磁盤保存Ehcache數據,默認是false.
diskExpiryThreadIntervalSeconds磁盤緩存的清理線程執行間隔,默認是120秒.
memoryStoreEvictionPolicy當內存緩存達到最大,有新的element加入的時候, 移除緩存中element的策略.默認是LRU(近期最少使用),可選的有LFU(最不常使用)和FIFO(先進先出)
  • mapper配置ehcache
<cache type="org.mybatis.caches.ehcache.EhcacheCache" eviction="LRU" flushInterval="60000" size="1024"readOnly="true"/>

還能夠依據需求調整當前namespace的緩存參數:

<cache type="org.mybatis.caches.ehcache.EhcacheCache"><property name="timeToIdleSeconds" value="3600"/><property name="timeToLiveSeconds" value="3600"/><!-- 同ehcache參數maxElementsInMemory --><property name="maxEntriesLocalHeap" value="1000"/><!-- 同ehcache參數maxElementsOnDisk --><property name="maxEntriesLocalDisk" value="10000000"/><property name="memoryStoreEvictionPolicy" value="LRU"/>
</cache>

二級緩存小結

  • 適用場景
    對于查詢請求多對查詢結果實時性要求不高的場景,可採用二級緩存減少數據庫負擔,提高訪問速度(業務場景如:微博/動態/訂單信息等).
  • 局限
    二級緩存對細粒度級別的緩存實現不好,如”緩存全部的商品信息時,二級緩存就無法實現當一個商品信息變化時僅僅刷新該商品緩存而不刷新全部商品緩存“,由于二級緩存區域以namespace為單位劃分,當一個商品發生變化會將全部商品緩存清空,因此解決此類問題須要在上層對數據進行業務劃分.

轉載于:https://www.cnblogs.com/jhcelue/p/7142311.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/254070.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/254070.shtml
英文地址,請注明出處:http://en.pswp.cn/news/254070.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

DM365視頻處理流程/DM368 NAND Flash啟動揭秘

DM365的視頻處理涉及到三個相關處理器&#xff0c;分別是視頻采集芯片、ARM處理器和視頻圖像協處理器&#xff08;VICP&#xff09;&#xff0c;整個處理流程由ARM核協調。視頻處理主要涉及三個處理流程&#xff0c;分別是視頻采集、視頻編碼和對編碼后的視頻的處理&#xff0c…

系統的Drawable(四)-LayerListDrawable

系統的Drawable(四)-LayerListDrawable 學習自 https://blog.csdn.net/u014695188/article/details/52815444 LayerListDrawable 漫談 使用layer-list可以將多個drawable按照順序層疊在一起顯示&#xff0c;默認情況下&#xff0c;所有的item中的drawable都會自動根據它附上vie…

圖像處理:鏡頭頻率(衍射極限) 和 相機采樣:顯微鏡的采樣定理

采樣定理大家都知道&#xff0c;相信不用多說。 我自己寫下來給自己看。 下面&#xff0c;我總結 大家平時照相的鏡頭或者顯微鏡的物鏡的情況下&#xff1a; 采樣頻率是指圖像在數字化的時候的過程&#xff0c;實際上就是我們相機感光元件CCD或者CMOS的一個個小像元把模擬的連續…

【練習】使用事務控制語句

1.使用show engines 命令確定系統中是否有任何事務存儲引擎可用以及哪個是默認引擎。 2.使用set autocommit 語句啟用autocommit。 3.為使用world數據庫做準備&#xff0c;確認city表使用事務存儲引擎innodb。 4.使用start transaction 語句顯式啟動新事務。 5.刪除一行。 6.使…

老男孩Day1作業(一):編寫登錄接口

要求&#xff1a;編寫登錄接口 1. 輸入用戶名和密碼 2. 認證成功后顯示歡迎信息 3. 輸錯三次后鎖定 1&#xff09;編寫思路 編寫思路參考下面GitHub鏈接中的流程圖 https://github.com/ChuixinZeng/PythonStudyCode/blob/master/PythonCode-OldBoy/Day1/作業/Day1_作業_登錄接口…

hashcat源碼分析1

typedef struct hash{void *digest;salt_t *salt;void *esalt;void *hook_salt; // additional salt info only used by the hook (host)int cracked;hashinfo_t *hash_info;char *pw_buf;int pw_len;} hash_t;一.1. 信號 函數&a…

Davinci及U-boot的一些介紹

TI推出的數字多媒體平臺DM系列&#xff0c;集成了ARM與DSP雙核處理器&#xff1a;DSP處理器運行DSP/BIOS操作系統&#xff0c;負責音視頻編解碼算法以及其他圖形處理算法&#xff1b;ARM處理器運行MontaVista Linux操作系統&#xff0c;負責設備初始化、用戶圖形界面管理。ARM處…

像素越多越好?像元的面積越小越好?為何底大一級壓死人?

像素越多越好&#xff1f;像素點的面積越小越好&#xff1f;為何底大一級壓死人&#xff1f; 像素是&#xff1a;圖像最小單元的數量&#xff0c;例如6000*4000&#xff0c;像素數量就是24*10^6。 像素太少當然圖像就看不見了&#xff0c;看不清晰了。 但是現在幾乎所有手機和相…

設計模式(5)--工廠模式

//5.工廠模式 //ver1 //回顧簡單工廠模式 class OperationFactory { public:static Operation createOperation(char chOper){Operation * op NULL;switch(chOper){case :op new OperationAdd();break;case -:op new OperationSub();break;default:break;}return *op;} };vo…

對于多屬性類型系統的數據庫設計

主要是以下幾類系統: 生活信息系統, 內容:小, 屬性:大,電商商品系統, 內容:大, 屬性:大,風控征信系統, 內容:小, 屬性:大,新聞系統, 內容:大, 屬性:小,這些系統共同的特點, 都是在主體內容上會攜帶多個屬性, 并且屬性需要隨時能調整, 并且要求能兼容舊屬性, 還需要頻繁的通過屬…

linux環境部署常用命令

1.  查看當前所屬目錄&#xff1a;pwd2.  回到上級目錄&#xff1a;cd ../回到上兩級目錄&#xff1a;cd ../ ../3.  查看當前目錄下有哪些文件&#xff1a;ls4.  查看最后100行日志&#xff1a;tail -100 catalina.out動態重看操作日志&#xff1a;tail -f catalina.o…

DM6446開發攻略:V4L2視頻驅動和應用分析

針對DAVINCI DM6446平臺&#xff0c;網絡上也有很多網友寫了V4L2的驅動&#xff0c;但只是解析Montavistalinux-2.6.10 V4L2的原理、結構和函數&#xff0c;深度不夠。本文決定把Montavista 的Linux-2.6.18 V4L2好好分析一下&#xff0c;順便講解在產品中的應用&#xff0c;滿足…

相機像素尺寸(像元大小)和成像系統分辨率之間的關系

相機像素尺寸&#xff08;像元大小&#xff09;和成像系統分辨率之間的關系 在顯微成像系統中&#xff0c;常常會用分辨率來評價其成像能力的好壞。這里的分辨率通常是指光學系統的極限分辨率以及成像探測器的圖像分辨率。最終圖像所呈現出的實際分辨率&#xff0c;取決于二者的…

H5網頁播放器播不了服務器上的mp4視頻文件

打開IIS&#xff0c;在功能視圖里找到MIME類型菜單&#xff0c;打開該菜單后鼠標右鍵添加.mp4擴展名的MIME類型video/mp4 其他視頻文件播放不了估計也得在IIS里添加對應的MIME類型&#xff08;從服務器下載文件時也得添加對應的MIME類型&#xff09; 轉載于:https://www.cnblog…

不定寬度居中

一、傳統方法 <div class"wrap"><div class"inner">html &#xff1a; 讓 inner 居中</div> </div> .wrap {float: left; /* 自適應內容寬度 */position: relative;left: 50%; } .inner {position: relative;left: -50%; } 二、…

文章目錄自動生成器

提供一個插件&#xff0c;可以實現segmentfault的文章目錄效果啦~~ 不止點擊跳轉還滾動激活當前鏈接 demo地址 使用很簡單 <!-- 文章容器 --> <div id"kCatelog"></div> <!-- 目錄容器 --> <div class"k-catelog-list" id"…

基于ARM+DSP進行應用開發-經驗共享

針對當前應用的復雜性&#xff0c;SOC芯片更好能能滿足應用和媒體的需求&#xff0c;集成眾多接口&#xff0c;用ARM做為應用處理器進行多樣化的應用開發和用戶界面和接口&#xff0c;利用DSP進行算法加速&#xff0c;特別是媒體的編解碼算法加速&#xff0c;既能夠保持算法的靈…

工業相機之全局曝光與卷簾曝光

曝光方式包括兩種&#xff1a; 全局曝光&#xff08;global shutter&#xff09;卷簾曝光&#xff08;rolling shutter&#xff09; CCD相機都是全局曝光&#xff0c;CMOS相機既有全局曝光也有卷簾曝光 全局曝光 全局曝光的方式比較簡單。也就是說光圈打開后&#xff0c;整個圖…

Hibernate入門注解筆記

Entity 代表實體 映射一張表 Table 定義表的屬性 Embeddable 定義類級別可以被嵌入 Id 指定主鍵 GeneratedValue 指定主鍵生成策略 Column指定列級別的屬性 Embedded 指定屬性為被包含類 將被包含類 作為 包含類的 字段屬性 寫入同一張表 EmbeddedId 指定包含類為特定主鍵 實…

.NET 環境中使用RabbitMQ

在企業應用系統領域&#xff0c;會面對不同系統之間的通信、集成與整合&#xff0c;尤其當面臨異構系統時&#xff0c;這種分布式的調用與通信變得越發重要。其次&#xff0c;系統中一般會有很多對實時性要求不高的但是執行起來比較較耗時的地方&#xff0c;比如發送短信&#…