言成言成啊 | Kit Chen's Blog

IDEA打包Jar的两种形式

发布于2024-03-31 18:35:33,更新于2024-04-01 19:14:07,标签:java  文章会持续修订,转载请注明来源地址:https://meethigher.top/blog

一、直接打包

首先,File-Project Structure-Artifacts-+-JAR(from modules with dependencies)

之后,Build-Build Artifacts-Rebuild,即可

二、Maven插件打包

在maven的pom.xml中添加如下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<!--jar包的入口函数-->
<mainClass>org.example.HttpTest</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

执行命令

1
mvn clean package
发布:2024-03-31 18:35:33
修改:2024-04-01 19:14:07
链接:https://meethigher.top/blog/2024/idea-package-jar/
标签:java 
付款码 打赏 分享
Shift+Ctrl+1 可控制工具栏