我正在尝试使用 Apache Commons Daemon procrun 从我的 Springboot jar 创建服务。当我尝试运行该服务时,出现“FindClass org/springframework/boot/loader/JarLauncher failed”错误。
在我的POM中我添加了:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
和
<packaging>jar</packaging>
完整的错误日志:
[2024-01-22 11:33:20] [info] [ 3780] Apache Commons Daemon procrun (1.3.4.0 64-bit) started.
[2024-01-22 11:33:20] [info] [ 3780] Running Service 'RESTApi'...
[2024-01-22 11:33:20] [info] [ 3536] Starting service...
[2024-01-22 11:33:21] [error] [ 5204] FindClass org/springframework/boot/loader/JarLauncher failed
[2024-01-22 11:33:21] [error] [ 5204] The specified procedure could not be found.
[2024-01-22 11:33:21] [error] [ 3536] Failed to start Java
[2024-01-22 11:33:21] [error] [ 3536] ServiceStart returned 4.
[2024-01-22 11:33:21] [info] [ 3780] Run service finished.
[2024-01-22 11:33:21] [info] [ 3780] Apache Commons Daemon procrun finished.
请帮我解决这个错误。我还接受其他易于操作的工具的建议。请注意,我无法使用 NSSM。
您可以尝试以下方法:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>main.class.here</mainClass>
<executable>true</executable>
</configuration>
</plugin>