Spring Boot & WinRun4J for Windows Service JAR:BOOT-INF 文件夹之外的服务启动类



我想使用winrun4j作为Windows服务运行Spring Boot应用程序。它不起作用,因为WinRun4J找不到主要类。我注意到这是因为Spring-boot-maven-Plugin在Boot-Inf文件夹中收集了来源,并且无法访问那里的类。这是错误跟踪:

[info] Registering natives for Native class
[info] Registering natives for FFI class
 [err] Could not find service class
 [err] Failed to initialise service: 1
java.lang.NoClassDefFoundError: SpringBootLauncherService
Caused by: java.lang.ClassNotFoundException: SpringBootLauncherService
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

有没有办法在boot-inf文件夹外部使用所需类的弹簧启动可执行罐?或也许您知道使用Spring boot和winrun4j <<<<strong>吗?/strong>

Spring-Boot-Maven-Plugin生成的JAR具有以下结构:

myapp-0.0.1-SNAPSHOT.jar
|--- org: Spring Boot Loader classes
|--- META-INF: maven/ & MANIFEST-MF
|--- BOOT-INF: lib/ & classes/

我相信我需要这样的东西:

myapp-0.0.1-SNAPSHOT.jar
|--- org: Spring Boot Loader classes
|--- META-INF: maven/ & MANIFEST-MF
|--- BOOT-INF: lib/ & classes/
|--- SpringBootLauncherService.class

我将感谢任何帮助。

我能够使其正常工作。

  • 我使用bootrepackage分类器属性迫使弹簧启动制作2个罐子:一个带有弹簧启动结构的罐子,另一个可用于其他目的的普通罐子,例如与winrun4j集成。这在使用Spring Boot应用程序中作为依赖项
  • 对此进行了很好的解释。
  • 我从可执行的jar中提取了lib,并将文件夹添加到winrun4j的INI文件中的类路径中。classpath.1=the-springboot-app.jar classpath.2=./lib/*
  • 仍然在INI文件中,我添加了vmarg.1=-Dloader.main=the.springboot.app.Application,以便使用Springboot PropertiesLaucher的SpringBootLauncherService类可以解决加载程序类。
  • service.class设置为ini至 service.class=the.springboot.app.SpringBootLauncherService

最新更新