[英]Can I make an executable jar with “build-info” by “Spring Boot Maven Plugin”?
I am trying to make an executable jar file with "Spring Boot Maven Plugin".我正在尝试使用“Spring Boot Maven Plugin”制作可执行的 jar 文件。
Usually, I can do this by setting "repackage".通常,我可以通过设置“重新打包”来做到这一点。 goal in my pom.xml file was set like this.
我的 pom.xml 文件中的目标是这样设置的。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.6.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
And my build command is like this:我的构建命令是这样的:
mvn clean package spring-boot:repackage
This works, but I want to have META-INF/build-info.properties in the jar file.这可行,但我想在 jar 文件中有META-INF/build-info.properties 。
By having this file, I can check build info in my springboot application, so I want to have it.通过拥有这个文件,我可以在我的 springboot 应用程序中检查构建信息,所以我想要它。
To generate " META-INF/build-info.properties " file, I need to set "build-info" goal.要生成“ META-INF/build-info.properties ”文件,我需要设置“build-info”目标。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.6.RELEASE</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
Well now I am in a dilemma because好吧,现在我进退两难了,因为
I want to have an executable jar with "META-INF/build-info.properties".我想要一个带有“META-INF/build-info.properties”的可执行jar。
I am pretty new to this maven process.我对这个 maven 过程很陌生。 Is there anyone who can help me?
有谁能帮助我吗?
I solved this issue.我解决了这个问题。 The problem was
spring-boot-maven-plugin
was in the wrong place.问题是
spring-boot-maven-plugin
放错了地方。 It was inside <pluginManagement>
.它在
<pluginManagement>
里面。 I moved this plugin to <plugins>
我将此插件移至
<plugins>
Like @Mark Bramnik answered, I can set both goal settings in pom.xml, and mvn clean package
command is enough!就像@Mark Bramnik 回答的那样,我可以在 pom.xml 中设置两个目标设置,并且
mvn clean package
命令就足够了!
You can run multiple goals of the same plugin.您可以运行同一个插件的多个目标。 So you can probably do something like this:
所以你可能可以做这样的事情:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.6.RELEASE</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.