0

我遇到了一种行为,即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

根据插件的文档,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 文件中的正确使用模式是什么,它产生了正确的可部署工件?

谢谢!

4

0 回答 0