问题在EC2中部署类似服务的springboot

时间:2018-09-11 12:19:19

标签: java spring-boot amazon-ec2

我通过以下方式运行应用程序:java -jar app.jar。工作正常!

但是安装程序像https://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html一样像服务一样运行。

sudo service ccth start时,发生以下错误:

/etc/init.d/ccth: line 1: $'PK\003\004': command not found

/etc/init.d/ccth: line 2:Dr�Lorg/PK: No such file or directory

/etc/init.d/ccth: line 3:Dr�Lorg/springframework/PK: No such file or directory

/etc/init.d/ccth: line 4:Dr�Lorg/springframework/boot/PK: No such file or directory

/etc/init.d/ccth: line 5: $'\bDr\376L': command not found

/etc/init.d/ccth: line 6:Dr�L%org/springframework/boot/loader/data/PK: No such file or directory

/etc/init.d/ccth: line 7:Dr�L/springframework/boot/loader/jar/PK: No such file or directory

/etc/init.d/ccth: line 8: syntax error near unexpected token `$'org/springframework/boot/loader/archive/PK\003\004''

/etc/init.d/ccth: line 8: Dr�L(org/springframework/boot/loader/archive/PK'

我该如何解决?

3 个答案:

答案 0 :(得分:1)

您很可能在构建配置中缺少<executable>选项。没有它,您将生成常规的JAR,而不是可执行的JAR。

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

答案 1 :(得分:1)

感谢您发布问题。我花了一些时间研究完全相同的问题。我使用gradle构建jar,需要包含以下内容:

bootJar {
    launchScript()
}

然后只需确保您运行新创建的文件。

答案 2 :(得分:0)

观看此Run Spring Boot App in EC2 Instance using S3视频

非常棒的视频教程。希望能回答您的问题!