zoukankan      html  css  js  c++  java
  • IDEA结合maven将依赖都打入jar包

    1、在pom.xml中添加插件

    <build>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <version>2.15.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
    
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
    
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass></mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <defaultGoal>compile</defaultGoal>
    </build>

    <mainClass></mainClass> 中写上你的main方法所在的类路径;


    2、maven将需要的插件加载完后,可以直接在IDEA的窗口中点击打包,

    如果需要可以先点击”clean”,clean完以后再点击”package”

    image


    最后会在target中生成两个jar包,一个是包含所有依赖的jar:clickLog-1.0-SNAPSHOT.jar

    一个是没有依赖的jar:original-clickLog-1.0-SNAPSHOT.jar

    image

  • 相关阅读:
    SWOT分析模型
    如果度过迷茫,是多些挫折还是少一些好呢?
    Ext.Net动态构建树TreePanel使用详解
    Ext.Net动态加载菜单执行事件
    通过教练提升领导力了解行为教练在何时无法发挥作用
    Ext.Net\ExtJs弹出消息Alert、MessageBox、Confirm使用详解
    把领导力转化为结果结果导向型领导力
    自由职业,我的半年总结
    关于自由职业的一些想法(采访整理)
    Ext.net文本输入框:Ext.form.TextField属性汇总
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/12167685.html
Copyright © 2011-2022 走看看