【问题标题】:How to specify the Launcher in Spring Boot Gradle?如何在 Spring Boot Gradle 中指定 Launcher?
【发布时间】:2016-07-10 03:53:09
【问题描述】:

Spring Boot 中有三个启动器:JarLauncher/PropertiesLauncher/WarLauncher。 对于可执行 jar,默认使用 JarLauncher。现在我想改用 PropertiesLauncher 以便我可以使用外部类路径。我怎么能指定这是 spring boot gradle 插件?

根据本文档D.3.1 Launcher manifest 的 D3.1,我可以像这样在 MANIFEST.MF 中指定主类:

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.mycompany.project.MyApplication

但是,在 Spring Boot Gradle 中,以下代码 sn -p 实际上指定了 Start-Class,而不是 Main-Class:

springBoot {
    mainClass = "com.sybercare.HealthServiceApplication"
}

我需要手动创建 MANIFIEST.MF 还是有更好的方法?

谢谢!

【问题讨论】:

    标签: gradle spring-boot launcher


    【解决方案1】:

    添加layout 属性:

    springBoot{
        mainClass = "com.sybercare.HealthServiceApplication"
        layout = "ZIP"
    }
    

    layout = ZIP 触发 SpringBoot 使用PropertiesLauncher

    【讨论】:

    • 非常感谢@pczeus。我一直在寻找这个解决方案,但无法轻易找到。你在哪里找到的文档?
    【解决方案2】:

    布局属性默认为基于存档类型(jar 或 war)的猜测。对于 PropertiesLauncher,布局是 ZIP(即使输出可能是 jar 文件)。

    https://docs.spring.io/autorepo/docs/spring-boot/1.2.0.M2/maven-plugin/usage.html

    【讨论】:

      猜你喜欢
      • 2018-04-10
      • 2019-06-25
      • 1970-01-01
      • 1970-01-01
      • 2016-01-08
      • 1970-01-01
      • 2022-10-25
      • 2018-12-18
      • 1970-01-01
      相关资源
      最近更新 更多