兼容性优化
This commit is contained in:
@@ -17,6 +17,8 @@ import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -48,6 +50,37 @@ public class WorkUtilsApplication implements CommandLineRunner {
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
// ==================== 启动诊断 ====================
|
||||
|
||||
/**
|
||||
* 应用就绪后验证所有 data/ 配置文件状态
|
||||
*/
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void onReady() {
|
||||
String[] files = {
|
||||
"project_paths.txt", "datasources.json",
|
||||
"damaged_repos.cache", "mybatis-generator.properties", "workutils.config"
|
||||
};
|
||||
java.nio.file.Path dataDir = java.nio.file.Paths.get(
|
||||
System.getProperty("user.dir"), "data");
|
||||
StringBuilder sb = new StringBuilder("data 目录文件状态:\n");
|
||||
for (String f : files) {
|
||||
java.nio.file.Path p = dataDir.resolve(f);
|
||||
try {
|
||||
if (java.nio.file.Files.exists(p)) {
|
||||
long size = java.nio.file.Files.size(p);
|
||||
sb.append(String.format(" %-35s %s%n", f,
|
||||
size > 0 ? size + " bytes ✓" : "0 bytes ✗ 空文件!"));
|
||||
} else {
|
||||
sb.append(String.format(" %-35s 不存在 ✗%n", f));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
sb.append(String.format(" %-35s 读取失败: %s%n", f, e.getMessage()));
|
||||
}
|
||||
}
|
||||
log.info(sb.toString());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
WinConsole.ensureUtf8();
|
||||
SpringApplication.run(WorkUtilsApplication.class, args);
|
||||
|
||||
Reference in New Issue
Block a user