spring boot 属性启动器无法使用 [英] spring boot properties launcher unable to use
问题描述
我正在尝试使用 Spring Boot 属性启动器
i am trying to use the spring boot properties launcher
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.springframework.boot.loader.PropertiesLauncher</mainClass>
</manifest>
<manifestEntries>
<Start-Class>com.att.hadoop.loader.run.Application</Start-Class>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
当我查看清单文件时,它看起来像这样
when i look at manifest file it looks like this
$ unzip -q -c hdfsloader-0.0.1-SNAPSHOT.jar META-INF/MANIFEST.MF
Manifest-Version: 1.0
Built-By: aq728y
Build-Jdk: 1.7.0_25
Start-Class: org.springframework.boot.loader.PropertiesLauncher
Created-By: Apache Maven 3.1.0
Spring-Boot-Version: 1.0.0.RC1
Main-Class: org.springframework.boot.loader.JarLauncher
Archiver-Version: Plexus Archiver
关于为什么我的 mainclass 和 startclass 是错误的任何想法
any ideas on why my mainclass and startclass are wrong
我想设置为
主类:org.springframework.boot.loader.PropertiesLauncher
Main-Class: org.springframework.boot.loader.PropertiesLauncher
起始类:com.att.hadoop.loader.run.Application
Start-Class: com.att.hadoop.loader.run.Application
推荐答案
spring-boot-maven-plugin 重写你的清单,特别是它管理 Main-Class
和 Start-Class
条目,所以你必须在那里配置那些(不是在 jar 插件中).manifest中的Main-Class
实际上是由boot插件的layout
属性控制的,例如
The spring-boot-maven-plugin rewrites your manifest, and in particular it manages the Main-Class
and Start-Class
entries, so you have to configure those there (not in the jar plugin). The Main-Class
in the manifest is actually controlled by the layout
property of the boot plugin, e.g.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.0.0.RC1</version>
<configuration>
<mainClass>${start-class}</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
布局属性默认为基于存档类型(JAR 或 WAR)的猜测.对于 PropertiesLauncher
,布局为ZIP".
The layout property defaults to a guess based on the archive type (JAR or WAR). For the PropertiesLauncher
the layout is "ZIP".
这篇关于spring boot 属性启动器无法使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!