使用IDEA打jar包的详细图文教程

1. 点击intellij idea左上角的"File"菜单 -> Project Structure

2. 点击"Artifacts" -> 绿色的"+" -> "JAR" -> Empty

3. Name栏填入自定义的名字,Output ditectory 选择 jar 包目标目录,Available Elements 里右击需要添加到 jar 包的文件,即可添加到左边的jar 包目录下,具体看下图。

!!!注意这里:需要将依赖也加入到左边,不然生成的 jar 包,启动时会报错。

选中所有依赖,右击【Put into Output Root】。

4.以上设置完之后, 点击应用,确定

或者使用下面这种方式:

6. 点击菜单中"Build" -> "Build Artifacts"。

7. 双击弹出框中待生成jar包下面的build即可,如下图

第二种打包方式(使用Maven的Packge打包)

在父 pom.xml 中就,加入如下配置:

复制代码
<build>
       <!-- 最终打包的名字 -->
       <finalName>springboot</finalName>

       <!--  手动指定文件夹为resources,加载java下所有的xml文件-->
       <resources>
           <resource>
               <directory>src/main/java</directory>
               <includes>
                   <include>**/*.xml</include>
               </includes>
           </resource>
           <resource>
               <directory>src/main/resources</directory>
               <includes>
                   <include>**/*.*</include>
               </includes>
           </resource>
       </resources>

       <plugins>
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
               <configuration>
                   <includeSystemScope>true</includeSystemScope>
               </configuration>
           </plugin>
       </plugins>
</build>

点击 IDEA 右侧的 Maven 点击 package 即可打包完成!

相关推荐
栈与堆1 天前
LeetCode-1-两数之和
java·数据结构·后端·python·算法·leetcode·rust
智航GIS1 天前
10.7 pyspider 库入门
开发语言·前端·python
副露のmagic1 天前
更弱智的算法学习 day25
python·学习·算法
hudawei9961 天前
Flask 与 FastAPI 对比分析
python·flask·fastapi
寻星探路1 天前
【Python 全栈测开之路】Python 基础语法精讲(一):常量、变量与运算符
java·开发语言·c++·python·http·ai·c#
智航GIS1 天前
10.5 PyQuery:jQuery 风格的 Python HTML 解析库
python·html·jquery
小兔崽子去哪了1 天前
机器学习,梯度下降,拟合,正则化,混淆矩阵
python·机器学习
缘友一世1 天前
PyCharm连接autodl平台服务(python解释器&jupyter lab)
python·jupyter·pycharm
a程序小傲1 天前
得物Java面试被问:方法句柄(MethodHandle)与反射的性能对比和底层区别
java·开发语言·spring boot·后端·python·面试·职场和发展
华研前沿标杆游学1 天前
2026走进滕讯:小游戏×大模型产业交流记
python