IDEA打包可执行jar文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.lingyiitech</groupId>
    <artifactId>SapDataTransfer</artifactId>
    <version>2.0</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <!--本地依赖-->
        <dependency>
            <groupId>com.sap</groupId>
            <artifactId>sapjco3</artifactId>
            <version>3.0.8</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/sapjco3.jar</systemPath>
        </dependency>
        
        <!--常规依赖-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.41</version>
        </dependency>
    </dependencies>
</project>

点击 File -- Project Structure

1、在 Libraries 中能看到pom.xml文件中所有的常规依赖

2、点击 Artifacts -- Add -- JAR -- From modules with dependencies

3、在 Main Class 中选择入口类,META-INF/MANIFEST.MF 文件的位置建议自动生成即可,也可以在工程目录内自定义

4、此时,在 Artifacts 右侧xxxxxxxx.jar下的预览窗格内应能看到工程的所有依赖(包括常规依赖和本地依赖)

5、主界面上点击 Build -- Build Artifacts -- build/Rebuild 开始打包,完成

posted @ 2023-05-29 14:56  谭五月  阅读(92)  评论(0)    收藏  举报