# mapper_refresh **Repository Path**: qiaomulzy_admin_admin/mapper-refresh ## Basic Information - **Project Name**: mapper_refresh - **Description**: mybatis mapper自动刷新 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-02-25 - **Last Updated**: 2022-02-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # mybatis mapper xml热刷新功能 ## 使用 **idea为例,在修改mapper之后,ctrl+shift+F9编译xml,等待刷新任务执行后即可生效**
![image.png](https://cdn.nlark.com/yuque/0/2020/png/1609104/1607248343391-417e8634-516b-4c63-b2c9-c34ca39d892b.png#align=left&display=inline&height=410&margin=%5Bobject%20Object%5D&name=image.png&originHeight=560&originWidth=761&size=44768&status=done&style=none&width=557)
## 接入 ### mapper-core 自动刷新插件的基础包,核心逻辑都在这里实现,只依赖mybatis,可脱离spring运行。
非spring接入示例 ```java public static void main(String[] args) { CoreServiceChain chain = new CoreServiceChain(); chain.setServiceProcessList(Arrays.asList(new RefreshResourceProcess())); File[] yourMapperFiles = new File[]{new File("you mapper file path ...")}; MyMapperRefresh myMapperRefresh = new MyMapperRefresh( sqlSessionFactory,yourMapperFiles,chain,true ); myMapperRefresh.run(); } ``` ### mapper-spring 这是spring接入的包,接入示例 ```xml ``` ### mapper-refresh-boot-start(推荐) springboot start接入 #### 可选配置(prefix = "mapper-refresh") | key | value | 注释 | | --- | --- | --- | | enabledRefresh | true/false | 是否开启自动刷新功能 | | mapperLocations | classpath*:mapper/**/*Mapper.xml | 配置同mybatis,
若不配,
优先取
mybatis.mapper-locations,
其次取
mybatis-plus.mapper-locations| | delaySeconds | 10 | 延迟启动时间,单位秒,不小于10秒 | | sleepSeconds | 20 | 刷新间隔,单位秒,不小于10秒 | ### 新增自定义的执行链(无特殊需求无需配置) ```java @Bean public List serviceProcesses(){ List serviceProcesses = Lists.newArrayList(); serviceProcesses.add(); ... return serviceProcesses; } ```
理论上在application.yml如下配置便可在你的项目中运行 ```java mapper-refresh: enabled-refresh: true ```