maven項目中 把依賴的jar包一起打包 轉

Maven1-HelloWorld簡單入門

使用Maven Assembly plugin將依賴打包進jar

1、pom.xml 配置文件:

在pom.xml配置文件中添加

<build>  
        <plugins>  
            <plugin>  
                <artifactId>maven-assembly-plugin</artifactId>  
                <configuration>  
                    <archive>  
                        <manifest>  
                            <mainClass>cn.bd.bdapp.batch.HfileByMapReduce</mainClass>  // 根據自己類名和路徑修改
                        </manifest>  
                    </archive>  
                    <descriptorRefs>  
                        <descriptorRef>jar-with-dependencies</descriptorRef>  
                    </descriptorRefs>  
                </configuration>  
            </plugin>  
        </plugins>  
    </build>

2、進入項目路徑打包

在項目路徑下執行:mvn assembly:assembly

如下圖表示打包成功:

3、找到文件打包的路徑

一般在項目target目錄下會生成一個:project-version-with-dependencies.jar文件

例如我的bdapp-3-jar-with-dependencies.jar

4、上傳該包即可。

本文參考地址:

http://lvjun106.iteye.com/blog/1849803

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章