【问题标题】:unable to create a service for SpringBoot on Linux Ubuntu 14.04.5 LTS无法在 Linux Ubuntu 14.04.5 LTS 上为 SpringBoot 创建服务
【发布时间】:2017-02-04 09:53:13
【问题描述】:

我刚刚在 Ubuntu 14.04.5(linode 服务器)上部署了一个 springboot 应用程序 1.4.1.RELEASE,但很难让它作为服务运行(启动、停止、重启)。我偶然发现了http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/html/deployment-install.html#deployment-service,但没有帮助。我目前无法将 Ubuntu 服务器升级到 16.04.1,因为其他应用程序都依赖于这个版本。我非常需要这方面的帮助。

  • 我试过跑步

    ~$ sudo ln -s /opt/xxxx/xxxx-0.0.1.jar /etc/init.d/xxxx-0.0.1

  • sudo service myapp start

但得到响应:xxxx-0.0.1: unrecognized service

请帮忙

【问题讨论】:

    标签: spring spring-boot spring-data ubuntu-14.04 executable-jar


    【解决方案1】:

    这看起来是个奇怪的问题。

    现在,我可以建议你做以下事情:

    • 检查您的*.jar 文件是否可执行。输入sudo chmod +x /opt/xxxx/xxxx-0.0.1.jar 确认并再次启动服务。
    • 尝试将*.jar 文件复制到/etc/init.d/ 目录而不是创建链接。输入cp /opt/xxxx/xxxx-0.0.1.jar /etc/init.d/ 并再次启动服务。

    如果有帮助,请告诉我。如果没有,也许我们可以想出一个不同的解决方案。

    问候

    【讨论】:

    • 谢谢,听从您的建议。我现在得到:/etc/init.d/xxxx-0.0.1: 2: /etc/init.d/xxxx-0.0.1: 语法错误:未终止的引号字符串。请注意,我的 jar 是可执行的,我可以使用 java -jar xxxx-0.0.1.jar 运行它
    【解决方案2】:

    非常高兴地解决了问题:)

    我不得不从

    更改我的 pom.xml 文件
              <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    

            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
    

    而且效果很好……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      • 1970-01-01
      • 2022-08-24
      • 2015-07-20
      • 2022-07-06
      相关资源
      最近更新 更多