Spring boot META-INF/build-info.properties 不在工件中

Mej*_*jmo 3 java spring-boot

我想在 /info 中访问我的提交信息。问题是,它在 IDE 中工作,但打包工件时似乎有问题,文件META-INF/build-info.properties没有打包到 jar 中!任何提示为什么?

    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
            <execution>
                <goals>
                    <goal>build-info</goal>
                </goals>
                <phase>package</phase>
            </execution>
        </executions>
        <configuration>
            <additionalProperties>
                <number>${buildNumber}</number>
                <job>${buildJob}</job>
            </additionalProperties>
        </configuration>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

lak*_*man 8

从执行中删除<phase>package</phase>,然后执行mvn clean install. 它应该生成META-INF/build-info.properties文件


小智 6

     <build>
        <plugins>
           <plugin>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-maven-plugin</artifactId>
              <version>${spring-boot.version}</version>
              <configuration>
                 <mainClass>${start-class}</mainClass>
                 <executable>true</executable>
              </configuration>
              <executions>
                 <execution>
                    <goals>
                        <goal>build-info</goal>
                        <goal>repackage</goal>
                    </goals>
                 </execution>
              </executions>
           </plugin>
Run Code Online (Sandbox Code Playgroud)