java - Maven创建2个归档文件

标签 java maven spring-boot

我正在使用 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/

相关文章:

java - 如何将一行中的元素解析到不同的哈希表中?

java - J2me RecordStore 错误 : java. lang.NullPointerException: 0 - 下面的代码有什么问题

java - Docker 将应用程序(服务)日志存储在文件夹中并及时清除它们

java - 如何在 Java 中将字符串 AM/PM 日期转换为时间戳?

java - 使用 swing 如何使未聚焦的文本字段变暗?

java - localsettings.properties : How to use its properties for JTest configuration?

java - Maven - 如何将单个资源文件放置在与其他资源文件不同的位置?

javascript - 我添加自定义过滤器来解决允许跨原点的问题,但仍然拒绝 Angular 仅发送选项方法,并且不发送 get 或 post

java - 将 json 插入 postgreSQL

Spring Boot 2 tomcat ssl握手缓存