spring boot属性启动程序无法使用

时间:2014-01-24 01:21:37

标签: spring-boot

我正在尝试使用spring boot属性启动器

<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>

当我查看清单文件时,它看起来像这样

$ 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错误的任何想法

我想将其设为

Main-Class:org.springframework.boot.loader.PropertiesLauncher

Start-Class:com.att.hadoop.loader.run.Application

1 个答案:

答案 0 :(得分:12)

spring-boot-maven-plugin重写你的清单,特别是它管理Main-ClassStart-Class条目,所以你必须在那里配置(不在jar插件中)。清单中的Main-Class实际上是由引导插件的layout属性控制的,例如

<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>

layout属性默认为基于归档类型(JAR或WAR)的猜测。对于PropertiesLauncher,布局为“ZIP”。