idea打包的两种方式

第一:idea使用maven打包jar包

1.在pom.xml中加入以下内容:

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

<dependencies>
     <!--其他的依赖包-->
</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                             <!--注意,此处必须是main()方法对应类的完整路径  -->
                        <mainClass>com.example.demo.test</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>assembly</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

注意:
要在 中写入带有main()方法的类的完整路径。
如果只写类名,可能会报错:Could not find or load main class

2、打包命令:
在这里插入图片描述
第二:idea自身打jar包

右击file选择标记的这个选项
在这里插入图片描述

在这里插入图片描述
main class设置类中具有main方法的类
下面那个选择src这个路径,如果之前打过包的话,会报错,将之前的MANIFEXT.MF那个文件删除就可以啦

在这里插入图片描述

下图中的圈上的打勾,然后应用并且ok就可以啦

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值