소스 검색

补上之前去除的while(true)

Caratacus 8 년 전
부모
커밋
1ed371942e
1개의 변경된 파일24개의 추가작업 그리고 22개의 파일을 삭제
  1. 24 22
      mybatis-plus/src/main/java/com/baomidou/mybatisplus/spring/MybatisMapperRefresh.java

+ 24 - 22
mybatis-plus/src/main/java/com/baomidou/mybatisplus/spring/MybatisMapperRefresh.java

@@ -145,34 +145,36 @@ public class MybatisMapperRefresh implements Runnable {
 					} catch (InterruptedException interruptedException) {
 						interruptedException.printStackTrace();
 					}
-					try {
-						for (String filePath : fileSet) {
-							File file = new File(filePath);
-							if (file.isFile() && file.lastModified() > beforeTime) {
-								globalConfig.setRefresh(true);
-								List<Resource> removeList = jarMapper.get(filePath);
-								if (removeList != null && !removeList.isEmpty()) {// 如果是jar包中的xml,将刷新jar包中存在的所有xml,后期再修改加载jar中修改过后的xml
-									for (Resource resource : removeList) {
-										runnable.refresh(resource);
+					do {
+						try {
+							for (String filePath : fileSet) {
+								File file = new File(filePath);
+								if (file.isFile() && file.lastModified() > beforeTime) {
+									globalConfig.setRefresh(true);
+									List<Resource> removeList = jarMapper.get(filePath);
+									if (removeList != null && !removeList.isEmpty()) {// 如果是jar包中的xml,将刷新jar包中存在的所有xml,后期再修改加载jar中修改过后的xml
+										for (Resource resource : removeList) {
+											runnable.refresh(resource);
+										}
+									} else {
+										runnable.refresh(new FileSystemResource(file));
 									}
-								} else {
-									runnable.refresh(new FileSystemResource(file));
 								}
 							}
+							if (globalConfig.isRefresh()) {
+								beforeTime = SystemClock.now();
+							}
+							globalConfig.setRefresh(true);
+						} catch (Exception exception) {
+							exception.printStackTrace();
 						}
-						if (globalConfig.isRefresh()) {
-							beforeTime = SystemClock.now();
+						try {
+							Thread.sleep(sleepSeconds * 1000);
+						} catch (InterruptedException interruptedException) {
+							interruptedException.printStackTrace();
 						}
-						globalConfig.setRefresh(true);
-					} catch (Exception exception) {
-						exception.printStackTrace();
-					}
-					try {
-						Thread.sleep(sleepSeconds * 1000);
-					} catch (InterruptedException interruptedException) {
-						interruptedException.printStackTrace();
-					}
 
+					} while (true);
 				}
 			}, "mybatis-plus MapperRefresh").start();
 		}