【问题标题】:Steps to run Spring Boot application as Windows service using winsw使用 winsw 将 Spring Boot 应用程序作为 Windows 服务运行的步骤
【发布时间】:2016-12-13 08:37:34
【问题描述】:

我如何将 Spring Boot 应用程序作为 Windows 服务运行,因为我正在关注 spring doc for winsw
步骤:

  1. 我下载了分发包。
  2. 下载的二进制文件是winsw.1.19.exe

接下来他们要求将winsw.exe 替换为myApp.exe,在安装指南中他们提到我需要编辑配置文件,但我不知道配置文件在哪里需要进行更改。

注意:我的 Spring Boot 应用程序已经作为服务运行,我需要将此服务作为 Windows 服务运行。

【问题讨论】:

    标签: spring-mvc spring-boot spring-integration


    【解决方案1】:

    winsw documentation 提到了这个configuration file 是什么,而您所指的文档还显示了an example 如何使用它。

    思路如下,将可执行文件重命名为myApp.exe,然后创建一个名为myApp.xml 的XML 配置文件。我通常是这样配置服务的(尽管它与 spring 示例有点不同):

    <service>
        <id>windowsServiceId</id> <!-- Change this -->
        <name>Readable name of the windows service</name><!-- Change this -->
        <description>Description of the windows service</description><!-- Change this -->
        <workingdirectory>%BASE%\</workingdirectory>
        <logpath>%BASE%\logs</logpath>
    
        <executable>java</executable>
        <arguments>-jar my-application.jar</arguments><!-- Change this -->
    </service>
    

    如果两者都有,可以运行以下命令安装windows服务:

    myApp.exe install
    

    【讨论】:

    • 我安装了winsw.exe并将其重命名为mySpringBootApp.exe,创建了mySpringBootApp.xml,.xml文件完全是单独的文件吗?和(mySpringBootApp.exe 和 mySpringBootApp.xml 被放在像 f:\myspringboot\ 好的东西中。现在我的疑问是在 .xml 文件中。
    • 以上评论的继续,请看我的mySpringBootApp.xml abcabc此服务为winswjava-Xrs -Xmx256m -jar "C:\User\Saba\pakagerequest \target\packagerequestservice-default-1.7.0.jar" --httpPort=8080rotate
    • 在您的问题中也发布 XML,还有什么现在不起作用?
    • 日志 r 生成 1.packagerequestservice-default.err.log 2.packagerequestservice-default.out.log 3.packagerequestservice-default.wrapper.log 并在 wrapper.log 中显示此 2016- 12-14 13:55:19 - 开始 java -Xmx256m -jar C:\Saba\packagerequestservice\target\packagerequestservice-default-1.7.0.jar 2016-12-14 13:55:19 - 开始 7852并在 err.log 中显示此异常 java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext. 和 **Error: A JNI error has occurred, please check your installation and try again 线程中的异常"main" **.我已经发布了 xml
    • @jamesaq12wsx 是的。首先停止应用程序 (myApp.exe stop),然后替换 JAR 并再次启动应用程序 (myApp.exe start)。
    猜你喜欢
    • 2018-09-15
    • 1970-01-01
    • 2021-09-24
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    • 2019-04-25
    • 1970-01-01
    • 2017-02-24
    相关资源
    最近更新 更多