我正在经历一种行为,即 spring-boot-maven-plugin 的这种配置:

<build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
.....

结果在jar中生成了以下(缩短的)manifest.mf文件:

Manifest-Version: 1.0
Implementation-Vendor: Pivotal Software, Inc.
Implementation-Title: submit-enrollment
Implementation-Version: 0.0.1-SNAPSHOT
Implementation-Vendor-Id: c.z.services
Built-By: sl
Build-Jdk: 1.7.0_76
Created-By: Apache Maven 3.2.5
Archiver-Version: Plexus Archiver

这导致有缺陷的 jar 无法运行 .

一旦从pom.xml中删除 pluginManagement 标记,生成的清单就会更改为以下更完整的版本,并且在jar执行期间一切都很好:

Manifest-Version: 1.0
Implementation-Vendor: Pivotal Software, Inc.
Implementation-Title: submit-enrollment
Implementation-Version: 0.0.1-SNAPSHOT
Implementation-Vendor-Id: c.z.services
Built-By: sl
Build-Jdk: 1.7.0_76
Start-Class: c.z.submit.enrollment.SubmitEnrollmentApplication
Created-By: Apache Maven 3.2.5
Spring-Boot-Version: 1.2.5.RELEASE
Main-Class: org.springframework.boot.loader.JarLauncher
Archiver-Version: Plexus Archiver

根据插件的docs,预期pluginManagement标记:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>1.2.5.RELEASE</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>

那么,pom.xml文件中这个插件的正确使用模式是什么产生了正确的可部署工件?

谢谢!