zoukankan      html  css  js  c++  java
  • Maven打包方式整理

    方法一 maven-jar-plugin和maven-dependency-plugin插件打包

    <build>
    	<plugins>
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-jar-plugin</artifactId>
    			<version>2.6</version>
    			<configuration>
    				<archive>
    					<manifest>
    						<addClasspath>true</addClasspath>
    						<classpathPrefix>lib/</classpathPrefix>
    						<mainClass>com.xxg.Main</mainClass>
    					</manifest>
    				</archive>
    			</configuration>
    		</plugin>
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-dependency-plugin</artifactId>
    			<version>2.10</version>
    			<executions>
    				<execution>
    					<id>copy-dependencies</id>
    					<phase>package</phase>
    					<goals>
    						<goal>copy-dependencies</goal>
    					</goals>
    					<configuration>
    						<outputDirectory>${project.build.directory}/lib</outputDirectory>
    					</configuration>
    				</execution>
    			</executions>
    		</plugin>
    	</plugins>
    </build>  

    方法二 maven-assembly-plugin插件打包

    <build>
    	<plugins>
     
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-assembly-plugin</artifactId>
    			<version>2.5.5</version>
    			<configuration>
    				<archive>
    					<manifest>
    						<mainClass>com.xxg.Main</mainClass>
    					</manifest>
    				</archive>
    				<descriptorRefs>
    					<descriptorRef>jar-with-dependencies</descriptorRef>
    				</descriptorRefs>
    			</configuration>
    		</plugin>
     
    	</plugins>
    </build>
    

    #支持mvn package打包

    <build>
    	<plugins>
     
    		<plugin>
    			<groupId>org.apache.maven.plugins</groupId>
    			<artifactId>maven-assembly-plugin</artifactId>
    			<version>2.5.5</version>
    			<configuration>
    				<archive>
    					<manifest>
    						<mainClass>com.xxg.Main</mainClass>
    					</manifest>
    				</archive>
    				<descriptorRefs>
    					<descriptorRef>jar-with-dependencies</descriptorRef>
    				</descriptorRefs>
    			</configuration>
    			<executions>
    				<execution>
    					<id>make-assembly</id>
    					<phase>package</phase>
    					<goals>
    						<goal>single</goal>
    					</goals>
    				</execution>
    			</executions>
    		</plugin>
     
    	</plugins>
    </build> 

    方法三 maven-shade-plugin插件打包

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

    #支持Spring框架版本

    <build>  
        <plugins>  
      
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-shade-plugin</artifactId>  
                <version>2.4.1</version>  
                <executions>  
                    <execution>  
                        <phase>package</phase>  
                        <goals>  
                            <goal>shade</goal>  
                        </goals>  
                        <configuration>  
                            <transformers>  
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">  
                                    <mainClass>com.xxg.Main</mainClass>  
                                </transformer>  
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                    <resource>META-INF/spring.handlers</resource>  
                                </transformer>  
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">  
                                    <resource>META-INF/spring.schemas</resource>  
                                </transformer>  
                            </transformers>  
                        </configuration>  
                    </execution>  
                </executions>  
            </plugin>  
      
        </plugins>  
    </build> 
  • 相关阅读:
    Hbase写数据,存数据,读数据的详细过程 分类: B7_HBASE 2015-03-15 20:11 117人阅读 评论(0) 收藏
    机器学习(十四):深度学习梯度优化算法(SGD SGD-M NAG AdaGrad RMSProp Adam )
    机器学习(十三):卷积神经网络(CNN)
    机器学习(十一):FP增长(FP-growth)
    机器学习(十):Apriori算法
    Gulp命令自动生成精灵图
    esLint参数设置
    js 监控iframe URL的变化
    React+Redux学习笔记:React+Redux简易开发步骤
    React组件实现越级传递属性
  • 原文地址:https://www.cnblogs.com/flame540/p/13652276.html
Copyright © 2011-2022 走看看