[英]Unable to create hazelcast cache in mybatis mapper annotation
我設計了數據訪問對象 mybatis 映射器來讀取 Mysql 數據庫中的只讀數據。
@Mapper
public interface XYZMapper {
@Select("SELECT TYPES FROM abc WHERE STORE_ID = #{storeId} and CUSTOMER_ID = #{customerId}")
public String getDisabledSubscriptions(@Param("storeId") int storeId, @Param("customerId") int customerId);
@Select("SELECT TYPES as messageTypes, NAME as eventName FROM abc WHERE STORE_ID = #{storeId}")
public EventSubscription getEventAllSubscriptions(@Param("storeId") int storeId);
http://mybatis.org/hazelcast-cache/
上面的鏈接提供了使用 hazelcast 進行緩存的解決方案。 這在我們將映射器配置為 xml 文件時使用。 我們如何使用注釋映射器將上述每個查詢緩存為 L2 緩存
通過以下步驟解決了問題
a) 帶有 SpringBootApplication 類的 @EnableCaching
b)在映射器中定義的每個數據庫方法中添加@Cacheable(“abc”)(您想要緩存)
c) 在資源文件夾中定義了 hazelcast.yml
榛播:網絡:加入:多播:啟用:真
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.