maven打所有的依赖jar

需求:

打包的时候打工程的所有依赖jar,然后直接在命令行下执行

java -jar  *.jar parm1 parm2 .....

实现:

步骤一:

pom中增加maven-assembly-plugin

<build>  
	<plugins>  
	    <plugin>  
		<artifactId>maven-assembly-plugin</artifactId>  
		<configuration>  
		    <archive>  
			<manifest>  
			    <mainClass>foo.Test</mainClass>  
			</manifest>  
		    </archive>  
		    <descriptorRefs>  
			<descriptorRef>jar-with-dependencies</descriptorRef>  
		    </descriptorRefs>  
		</configuration>  
	    </plugin>  
	</plugins>  
</build>

步骤二:

mvn命令行或者eclipse配置

shell:mvn install  assembly:assembly  
eclipse:install assembly:assembly  

打包完成之后就会有个*.jar-with-dependencies.jar

你可能感兴趣的:(maven)