zoukankan      html  css  js  c++  java
  • maven项目用assembly打包可执行jar包

    该方法只可打包非spring项目的可执行jar包,spring项目可参考:http://www.cnblogs.com/guazi/p/6789679.html

    1.添加maven插件:

    <!-- Maven Assembly Plugin -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.4.1</version>
                        <configuration>
                            <!-- get all project dependencies -->
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <!-- MainClass in mainfest make a executable jar -->
                            <archive>
                              <manifest>
                                <mainClass>com.jobscrawler.crawlers.ShhCrawler</mainClass>
                              </manifest>
                            </archive>
         
                        </configuration>
                        <executions>
                          <execution>
                            <id>make-assembly</id>
                                                <!-- bind to the packaging phase -->
                            <phase>package</phase> 
                            <goals>
                                <goal>single</goal>
                            </goals>
                          </execution>
                        </executions>
                    </plugin>

    2.mvn clean(清理下项目)

    3.maven update project

    4.命令后执行命令mvn assembly:assembly -Dmaven.test.skip

      进入target目录会看到这两个jar包:

        jobscrawler-1.0-SNAPSHOT-jar-with-dependencies.jar
        jobscrawler-1.0-SNAPSHOT.jar

    5.执行 java -jar jobscrawler-1.0-SNAPSHOT-jar-with-dependencies.jar

    如果这个不管用,可以参考http://www.cnblogs.com/liqiu/p/3816068.html

    http://www.cnblogs.com/liqiu/p/4508848.html

    ---恢复内容结束---

  • 相关阅读:
    XML Schema
    Magento 2 instantiate object by Factory Objects
    Magento 2 Factory Objects
    UML类图与类的关系详解
    Magento add product attribute and assign to all group
    MyISAM 和InnoDB的区别
    Finding the Right EAV Attribute Table
    Implement Trie (Prefix Tree)
    Graph Valid Tree
    Maximum Subarray III
  • 原文地址:https://www.cnblogs.com/guazi/p/6789703.html
Copyright © 2011-2022 走看看