zoukankan      html  css  js  c++  java
  • maven 将项目打成jar包

    添加此plugin到项目的pom.xml

    <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>fuck</groupId>
        <artifactId>notGood</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>

        <name>notGood</name>
        <url>http://maven.apache.org</url>
        <repositories>
            <repository>
                <id> central</id>
                <name> Maven Repository Switchboard</name>
                <layout> default</layout>
                <url>http://repo1.maven.org/maven2</url>
            </repository>
        </repositories>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        </properties>

        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-core</artifactId>
                <version>1.2.1</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>fuck.notGood.JobRun</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>
                                jar-with-dependencies
                            </descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>
            </plugins>
        </build>

    </project> 

    注意修改mainClass为main的入口类文件 

    <mainClass>fuck.notGood.JobRun</mainClass>

    添加这个assmbly插件便可以打jar包了。在eclipse中,右键项目Run as->maven build 在Goals中输入assembly:assembly,点击run就可以了

    执行成功后会在target文件夹下多出一个以-jar-with-dependencies结尾的JAR包. 这个JAR包就包含了项目所依赖的所有JAR的CLASS.
  • 相关阅读:
    [OpenGL(C)] 旋转立体三角形
    [MSSQL] (命令)列出所有表.字段名.主键.类型.长度.小数位数等信息
    [端口] 端口大全及端口关闭方法
    [网络] IP的划分,超详细
    [C++] 面向对象院校管理系统
    [JSVM2] (开源)JS星际争霸(for JSVM2)
    [MSSQL,MySQL,Oracle] Join用法
    [其它] .NET 世界排名榜
    [C] (回溯法)计算总费用最小费用
    [OpenGL(Win32)] 3D 轮廓字体
  • 原文地址:https://www.cnblogs.com/vincent4code/p/5484212.html
Copyright © 2011-2022 走看看