首页 > 代码库 > idea 打包java程序

idea 打包java程序

创建maven项目

在pom.xml中添加:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.test.Test</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


指定主类

com.test.Test.java   :
package com.test;
import com.netflix.conductor.common.metadata.tasks.TaskDef;

public class Test {

public static void main(String[] args){
TaskDef t = new TaskDef("test_task");
System.out.println(t.toString());
}
}

导入第三方包:
File - Project Structure - Modules - Dependencies - 加号
打包(第三方包放到项目jar包外部的lib文件夹中):
File - Project Structure - Artifacts -
点击"+"选择jar,然后选择"from modules with dependencies"
选择“Main Class”后,选择Java,需要改成:D:\workshop\DbUtil\src\main\resources(需要新建文件夹)
右键output root创建lib文件夹,将第三方包拖入lib文件夹中 -
点击项目jar包,编辑Class Path: lib/conductor-common-1.7.5.jar - Apply
Build - Build Artifacts - Build/Rebuild



idea 打包java程序