gpt4 book ai didi

java - Maven创建2个归档文件

转载 作者:行者123 更新时间:2023-12-02 01:31:18 24 4
gpt4 key购买 nike

我正在使用 Maven 来构建我的项目。在我放入父 pom 之前它工作得很好。现在,该项目仍在构建,但输出是 2 个 jar 文件,而不是 1 个。其中一个以 -boot.jar 结尾,并且似乎是正确的 jar 文件,因为它包含所有依赖项,并且大小超过 60mb。另一个文件具有正确的名称 (projectId-version.jar),但小于 1mb,这是管道进程拾取的文件,但部署失败。

我需要 mvn 来构建一个包含所有依赖项的 jar。

我正在使用 Spring boot 1.5.19 (父 pom 有此依赖项)。有什么想法吗?

最佳答案

请参阅 spring boot maven 插件使用和说明文档。

https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/maven-plugin/repackage-mojo.html

https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-maven-plugin.html

特别是重新打包目标。您正在使用的父 POM 必须配置为设置新 Artifact ,以通过 classifier 配置添加 boot.jar

Classifier to add to the repackaged archive. If not given, the main artifact will be replaced by the repackaged archive. If given, the classifier will also be used to determine the source archive to repackage: if an artifact with that classifier already exists, it will be used as source and replaced. If no such artifact exists, the main artifact will be used as source and the repackaged archive will be attached as a supplemental artifact with that classifier. Attaching the artifact allows to deploy it alongside to the original one,

您可以定义 Maven 插件的配置设置并覆盖父级中定义的任何内容。

    <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<classifier></classifier>
</configuration>
</plugin>

关于java - Maven创建2个归档文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56010315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com