2

WindowsサービスとしてprunsrvインストールするためにApacheサービスを使用しています。jarサービスがシャットダウンされると、アプリケーションがクラッシュします。

set PR_STARTMETHOD=main
set PR_STOPMETHOD=exit

私のスタートアップとシャットダウンのクラスは次のようになります。

public class TravelportMainApp {
    private static ConfigurableApplicationContext ctx;

    public static void main(String[] args) {
        ctx = SpringApplication.run(source, args);
        ctx.registerShutdownHook();
    }

    public static void exit(String[] args) throws InterruptedException {
        if (ctx != null && ctx instanceof AbstractApplicationContext) {
            ((AbstractApplicationContext) ctx).destroy();
        }
        Sysout("EXIT OK.");
    }
}

結果: 終了コマンド "EXIT OK" が出力されますが、コマンド ライン アプリがクラッシュし、"commons daemon service runner is not working already." というメッセージが表示されます。ここで何が問題なのですか?

4

1 に答える 1

1

私は次のようになりました:

public static void exit(String[] args) throws InterruptedException {
    SpringApplication.exit(ctx);
    System.exit(0);
}
于 2015-05-27T10:02:47.300 に答える