我通过以下方式运行应用程序: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'
我该如何解决?
最佳答案
您很可能在构建配置中缺少<executable>
选项。没有它,您将生成常规的JAR,而不是可执行的JAR。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>