diff --git a/pom.xml b/pom.xml index 1946363..08d2a2f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.aohe sane-service - 0.3.1 + 0.3.2 aohe-sane-service @@ -71,6 +71,12 @@ 3.4.1 no-natives + + io.github.sanyarnd + app-locker + 1.2.0 + + diff --git a/src/main/java/org/aohe/Main.java b/src/main/java/org/aohe/Main.java index e20a0a7..55ee1e4 100644 --- a/src/main/java/org/aohe/Main.java +++ b/src/main/java/org/aohe/Main.java @@ -1,6 +1,7 @@ package org.aohe; import com.formdev.flatlaf.FlatDarculaLaf; +import io.github.sanyarnd.applocker.AppLocker; import lombok.extern.slf4j.Slf4j; import org.aohe.core.sane.utils.SaneSessionUtils; import org.aohe.core.swing.NewWindow; @@ -14,13 +15,21 @@ import javax.swing.*; public class Main { public static void main(String[] args) { + log.info(" 当前系统类型: {}", SystemUtils.getOsName()); - try { + try (AppLocker locker = AppLocker.create("aoheSaneServiceLock").build()){ + //启动锁,只允许启动一个 + locker.lock(); + //设置窗口主题 //FlatLightLaf.setup(); UIManager.setLookAndFeel(new FlatDarculaLaf()); } catch (UnsupportedLookAndFeelException e) { throw new RuntimeException(e); + } catch (Exception ex) { + log.info("应用已经启动,当前进程退出。"); + + System.exit(0); } //初始化其他资源 init();