如何指定要使用的不同启动器。我想使用M5版本中添加的PropertiesLauncher
我尝试修改 mainfest 文件以强制它使用 PropertiesLauncher 类,它可以工作,但会抛出此错误]
$ java -jar hdfspub-0.0.1-SNAPSHOT.jar
2013 年 10 月 28 日下午 12:42:44 org.springframework.boot.loader.PropertiesLauncher 初始化属性
信息:找到:application.properties 十月 28, 2013 12:42:44 PM org.springframework.boot.loader.PropertiesLauncher 初始化路径 信息:嵌套存档路径:[lib/]
2013 年 10 月 28 日下午 12:42:44 org.springframework.boot.loader.PropertiesLauncher getClassPathArchives 信息:从 lib/添加类路径条目
java.lang.IllegalStateException:未指定“Start-Class” list 条目 在 org.springframework.boot.loader.archive.Archive.getMainClass(Archive.java:52) 在 org.springframework.boot.loader.PropertiesLauncher.getMainClass(PropertiesLauncher.java:298) 在 org.springframework.boot.loader.Launcher.launch(Launcher.java:53) 在 org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:343) 所以看起来它在包含没有指定 Start-Class 的 jar 时失败了..
最佳答案
当您使用“java -jar ...”时,它会在 META-INF/MANIFEST.MF 中查找 Main-Class 属性。 Spring 与此无关。如果您使用 spring-boot-tools 构建 jar,那么会猜测 Main-Class,并且我认为 M5 中没有任何支持覆盖它。在最近的快照中,您可以将“布局”指定为 ZIP,例如
apply plugin: "spring-boot"
springBoot {
layout = 'ZIP'
}
或者在 Maven 中
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
</configuration>
</plugin>
关于spring - 指定要使用的启动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19640623/