Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Copy spring boot packaged fatjar to another directory

未关闭
#20 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
35/100
Issue 类型
文档
描述清晰度
需要澄清
活跃度
停滞
技术栈
spring-boot
领域
documentation

调研方向

Review the repository's existing programming-tip structure before deciding where this material belongs. Use the Maven install-phase guidance and the three listed copying options as the source, and consider the work done when the fat JAR copying instructions are added in the repository's established format with the relevant command and phase details.

由索引模型根据 Issue 内容生成。

描述

There are at last 3 options to fulfill this case.

Option 1.By maven-resource-plugin:
https://stackoverflow.com/questions/6689511/how-to-place-the-output-jar-into-another-folder-with-maven#comment7915129_6689511

https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
    <executions>
        <execution>
            <id>copy-files-on-build</id>
            <phase>install</phase>
            <goals>
                <goal>copy-resources</goal>
            </goals>
            <configuration>
                <outputDirectory>${basedir}/[TO-DIR]</outputDirectory>
                <resources>
                    <resource>
                        <directory>[FROM-DIR]</directory>
                        <!--<include>*.[MIME-TYPE]</include>-->
                        <filtering>false</filtering>
                    </resource>
                </resources>
            </configuration>
        </execution>
    </executions>
</plugin>

Option 2: By maven assembly plugin

https://maven.apache.org/plugins/maven-assembly-plugin/usage.html

        <!-- when running  mvn install , copy my-web.jar to APP-META/docker/config folder automatically(for docker build)  -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>copy-installed</id>
                        <phase>install</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <version>${project.version}</version>
                                    <type>${project.packaging}</type>
                                    <destFileName>my-web.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>../APP-META/docker-config/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Option 3: By ant run plugin
https://stackoverflow.com/questions/6689511/how-to-place-the-output-jar-into-another-folder-with-maven#comment7915129_6689511

Notes: You should execute the goal at the install phase, not the package phase. The origin jar file in install phase does not contain necessary dependencies in the file content. while the jar file in the install phase contains the necessary dependencies in it which is repackaged by spring boot plugin.

install

maven command
run mvn package install instead of mvn package, to copy the final jar to expected output directory.

主要语言
Python
星标
5
派生
2
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

davideuler/programming-tips 的其他 Issue

查看 davideuler/programming-tips 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。