一、直接打包
首先,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"> <mainClass>org.example.HttpTest</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build>
|
执行命令