Просмотр исходного кода

补充文档,去除一个构造.

nieqiurong 9 лет назад
Родитель
Сommit
d959214c9c

+ 3 - 10
mybatis-plus/src/main/java/com/baomidou/mybatisplus/refresh/MapperRefresh.java

@@ -53,23 +53,16 @@ public class MapperRefresh implements Runnable{
      */
     private static Map<String,List<Resource>> jarMapper = new HashMap<String, List<Resource>>();
 
-    public MapperRefresh(Resource[] mapperLocations, SqlSessionFactory sqlSessionFactory, int delaySeconds, int sleepSeconds) {
+    public MapperRefresh(Resource[] mapperLocations, SqlSessionFactory sqlSessionFactory, int delaySeconds, int sleepSeconds,boolean enabled){
         this.mapperLocations = mapperLocations;
         this.sqlSessionFactory = sqlSessionFactory;
         this.delaySeconds = delaySeconds;
-        this.enabled = true;
+        this.enabled = enabled;
         this.sleepSeconds = sleepSeconds;
         this.run();
     }
 
-    public MapperRefresh(Resource[] mapperLocations, SqlSessionFactory sqlSessionFactory) {
-        this.mapperLocations = mapperLocations;
-        this.sqlSessionFactory = sqlSessionFactory;
-        this.run();
-
-    }
-
-    public MapperRefresh(Resource[] mapperLocations, SqlSessionFactory sqlSessionFactory, boolean enabled) {
+    public MapperRefresh(Resource[] mapperLocations, SqlSessionFactory sqlSessionFactory, boolean enabled){
         this.mapperLocations = mapperLocations;
         this.sqlSessionFactory = sqlSessionFactory;
         this.enabled = enabled;

+ 24 - 0
mybatis-plus/src/test/resources/wiki/spring-config.md

@@ -119,6 +119,30 @@
 	| -->
 </configuration>
 ```
+...
+开启动态加载mapper
+    参数说明:
+        sqlSessionFactory:session工厂
+        mapperLocations:mapper匹配路径
+        enabled:是否开启动态加载  默认:false
+        delaySeconds:项目启动延迟加载时间  单位:秒  默认:10s
+        sleepSeconds:刷新时间间隔  单位:秒 默认:20s
+    提供了两个构造,挑选一个配置进入spring配置文件即可:
+    构造1:
+    <bean class="com.baomidou.mybatisplus.refresh.MapperRefresh">
+        <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
+        <constructor-arg name="mapperLocations" value="classpath*:mybatis/mappers/*/*.xml"/>
+        <constructor-arg name="enabled" value="true"/>
+    </bean>
+    构造2:
+     <bean class="com.baomidou.mybatisplus.refresh.MapperRefresh">
+         <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
+         <constructor-arg name="mapperLocations" value="classpath*:mybatis/mappers/*/*.xml"/>
+         <constructor-arg name="delaySeconds" value="10"/>
+         <constructor-arg name="sleepSeconds" value="20"/>
+         <constructor-arg name="enabled" value="true"/>
+     </bean>
+...