#采用 setDefaultUncaughtExceptionHandler 進行全局兜底
public static void main(String[] args) {
Thread.setDefaultUncaughtExceptionHandler((thread, ex) -> {
System.err.println("全局捕獲異常: " + ex.getMessage());
ex.printStackTrace();
System.exit(1);
});
throw new RuntimeException("測試未捕獲異常");
}