最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用maven生成可執(zhí)行的jar包的方法

 更新時間:2018年06月25日 10:17:17   作者:justinzhang  
這篇文章主要介紹了使用maven生成可執(zhí)行的jar包的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

本文介紹了使用maven生成可執(zhí)行的jar包的方法,分享給大家,具體如下:

從pom的xsi中可以打開描述pom的schema:

可以看到pom中,project的結(jié)構(gòu):

默認的mvn install生成的jar是不帶主類入口的,需要在maven-compile-plugin中設(shè)置主類,

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <groupId>com.cetc.di</groupId>
 <artifactId>hellocetc</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <packaging>jar</packaging>

 <name>hellocetc</name>
 <url>http://maven.apache.org</url>



 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>

 <dependencies>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 
 
<build>
<pluginManagement>
<plugins>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
    <archive>
      <manifest>
        <mainClass>com.cetc.di.hellocetc.App</mainClass>
        <addClasspath>true</addClasspath>
      <classpathPrefix>lib/</classpathPrefix>
      </manifest>

    </archive>
    <classesDirectory>
    </classesDirectory>
  </configuration>
</plugin>
</plugins>  
</pluginManagement>
</build> 
</project>

執(zhí)行mvn install:

在target目錄中,發(fā)現(xiàn)jar包已經(jīng)生成:

用java decompiler,可以看到manifest中已經(jīng)加入了MainClass:

使用mvn help:effective-pom可以看到pom.xml的完整結(jié)構(gòu)(包括繼承而來的屬性):

[INFO] Scanning for projects...
[INFO]                                     
[INFO] ------------------------------------------------------------------------
[INFO] Building hellocetc 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-help-plugin:2.2:effective-pom (default-cli) @ hellocetc ---
[INFO] 
Effective POMs, after inheritance, interpolation, and profiles are applied:

<!-- ====================================================================== -->
<!--                                    -->
<!-- Generated by Maven Help Plugin on 2015-11-18T08:05:12         -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/        -->
<!--                                    -->
<!-- ====================================================================== -->

<!-- ====================================================================== -->
<!--                                    -->
<!-- Effective POM for project 'com.cetc.di:hellocetc:jar:0.0.1-SNAPSHOT'  -->
<!--                                    -->
<!-- ====================================================================== -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.cetc.di</groupId>
 <artifactId>hellocetc</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <name>hellocetc</name>
 <url>http://maven.apache.org</url>
 <properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>
 <dependencies>
  <dependency>
   <groupId>junit</groupId>
   <artifactId>junit</artifactId>
   <version>3.8.1</version>
   <scope>test</scope>
  </dependency>
 </dependencies>
 <repositories>
  <repository>
   <snapshots>
    <enabled>false</enabled>
   </snapshots>
   <id>central</id>
   <name>Central Repository</name>
   <url>https://repo.maven.apache.org/maven2</url>
  </repository>
 </repositories>
 <pluginRepositories>
  <pluginRepository>
   <releases>
    <updatePolicy>never</updatePolicy>
   </releases>
   <snapshots>
    <enabled>false</enabled>
   </snapshots>
   <id>central</id>
   <name>Central Repository</name>
   <url>https://repo.maven.apache.org/maven2</url>
  </pluginRepository>
 </pluginRepositories>
 <build>
  <sourceDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\java</sourceDirectory>
  <scriptSourceDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\scripts</scriptSourceDirectory>
  <testSourceDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\test\java</testSourceDirectory>
  <outputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\classes</outputDirectory>
  <testOutputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\test-classes</testOutputDirectory>
  <resources>
   <resource>
    <directory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\main\resources</directory>
   </resource>
  </resources>
  <testResources>
   <testResource>
    <directory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\src\test\resources</directory>
   </testResource>
  </testResources>
  <directory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target</directory>
  <finalName>hellocetc-0.0.1-SNAPSHOT</finalName>
  <pluginManagement>
   <plugins>
    <plugin>
     <artifactId>maven-antrun-plugin</artifactId>
     <version>1.3</version>
    </plugin>
    <plugin>
     <artifactId>maven-assembly-plugin</artifactId>
     <version>2.2-beta-5</version>
    </plugin>
    <plugin>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.8</version>
    </plugin>
    <plugin>
     <artifactId>maven-release-plugin</artifactId>
     <version>2.3.2</version>
    </plugin>
    <plugin>
     <artifactId>maven-jar-plugin</artifactId>
     <version>2.4</version>
     <configuration>
      <source>1.8</source>
      <target>1.8</target>
      <archive>
       <manifest>
        <mainClass>com.cetc.di.hellocetc.App</mainClass>
        <addClasspath>true</addClasspath>
        <classpathPrefix>lib/</classpathPrefix>
       </manifest>
      </archive>
      <classesDirectory />
     </configuration>
    </plugin>
   </plugins>
  </pluginManagement>
  <plugins>
   <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.5</version>
    <executions>
     <execution>
      <id>default-clean</id>
      <phase>clean</phase>
      <goals>
       <goal>clean</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.6</version>
    <executions>
     <execution>
      <id>default-testResources</id>
      <phase>process-test-resources</phase>
      <goals>
       <goal>testResources</goal>
      </goals>
     </execution>
     <execution>
      <id>default-resources</id>
      <phase>process-resources</phase>
      <goals>
       <goal>resources</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.4</version>
    <executions>
     <execution>
      <id>default-jar</id>
      <phase>package</phase>
      <goals>
       <goal>jar</goal>
      </goals>
      <configuration>
       <source>1.8</source>
       <target>1.8</target>
       <archive>
        <manifest>
         <mainClass>com.cetc.di.hellocetc.App</mainClass>
         <addClasspath>true</addClasspath>
         <classpathPrefix>lib/</classpathPrefix>
        </manifest>
       </archive>
       <classesDirectory />
      </configuration>
     </execution>
    </executions>
    <configuration>
     <source>1.8</source>
     <target>1.8</target>
     <archive>
      <manifest>
       <mainClass>com.cetc.di.hellocetc.App</mainClass>
       <addClasspath>true</addClasspath>
       <classpathPrefix>lib/</classpathPrefix>
      </manifest>
     </archive>
     <classesDirectory />
    </configuration>
   </plugin>
   <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <executions>
     <execution>
      <id>default-compile</id>
      <phase>compile</phase>
      <goals>
       <goal>compile</goal>
      </goals>
     </execution>
     <execution>
      <id>default-testCompile</id>
      <phase>test-compile</phase>
      <goals>
       <goal>testCompile</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.12.4</version>
    <executions>
     <execution>
      <id>default-test</id>
      <phase>test</phase>
      <goals>
       <goal>test</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.4</version>
    <executions>
     <execution>
      <id>default-install</id>
      <phase>install</phase>
      <goals>
       <goal>install</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.7</version>
    <executions>
     <execution>
      <id>default-deploy</id>
      <phase>deploy</phase>
      <goals>
       <goal>deploy</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   <plugin>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.3</version>
    <executions>
     <execution>
      <id>default-site</id>
      <phase>site</phase>
      <goals>
       <goal>site</goal>
      </goals>
      <configuration>
       <outputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site</outputDirectory>
       <reportPlugins>
        <reportPlugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-project-info-reports-plugin</artifactId>
        </reportPlugin>
       </reportPlugins>
      </configuration>
     </execution>
     <execution>
      <id>default-deploy</id>
      <phase>site-deploy</phase>
      <goals>
       <goal>deploy</goal>
      </goals>
      <configuration>
       <outputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site</outputDirectory>
       <reportPlugins>
        <reportPlugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-project-info-reports-plugin</artifactId>
        </reportPlugin>
       </reportPlugins>
      </configuration>
     </execution>
    </executions>
    <configuration>
     <outputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site</outputDirectory>
     <reportPlugins>
      <reportPlugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-project-info-reports-plugin</artifactId>
      </reportPlugin>
     </reportPlugins>
    </configuration>
   </plugin>
  </plugins>
 </build>
 <reporting>
  <outputDirectory>D:\Users\a\Workspaces\MyEclipse 2015\hellocetc\target\site</outputDirectory>
 </reporting>
</project>

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.526 s
[INFO] Finished at: 2015-11-18T20:05:12+08:00
[INFO] Final Memory: 10M/245M
[INFO] ------------------------------------------------------------------------

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • java使用Jdom實現(xiàn)xml文件寫入操作實例

    java使用Jdom實現(xiàn)xml文件寫入操作實例

    這篇文章主要介紹了java使用Jdom實現(xiàn)xml文件寫入操作的方法,以完整實例形式分析了Jdom針對XML文件寫入操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-10-10
  • Java異常處理深入理解

    Java異常處理深入理解

    這篇文章主要介紹了java項目常用異常處理匯總,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
    2021-07-07
  • SpringCloud使用AOP統(tǒng)一處理Web請求日志實現(xiàn)步驟

    SpringCloud使用AOP統(tǒng)一處理Web請求日志實現(xiàn)步驟

    這篇文章主要為大家介紹了SpringCloud使用AOP統(tǒng)一處理Web請求日志實現(xiàn)步驟,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-08-08
  • JDBC獲取數(shù)據(jù)庫連接由淺入深

    JDBC獲取數(shù)據(jù)庫連接由淺入深

    大家好,本篇文章主要講的是JDBC獲取數(shù)據(jù)庫連接由淺入深,感興趣的同學趕快來看一看吧,對你有幫助的話記得收藏一下
    2022-02-02
  • springboot責任鏈模式實現(xiàn)多級校驗

    springboot責任鏈模式實現(xiàn)多級校驗

    責任鏈模式是將鏈中的每一個節(jié)點看作是一個對象,每個節(jié)點處理的請求不同,且內(nèi)部自動維護一個下一節(jié)點對象,下面我們來聊聊springboot如何利用責任鏈模式實現(xiàn)多級校驗吧
    2024-11-11
  • Spring AOP的使用詳解

    Spring AOP的使用詳解

    這篇文章主要介紹了Spring AOP的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-05-05
  • 教你如何輕松學會Java快慢指針法

    教你如何輕松學會Java快慢指針法

    要想把搬磚的效率提高,我們肯定是逃不掉數(shù)據(jù)結(jié)構(gòu)和算法知識的,這不,可愛的小編今天就和大家一起學習來了,今天給大家分享的是快慢指針,那啥是快慢指針呢,文中有非常詳細的解釋,需要的朋友可以參考下
    2021-06-06
  • Java仿12306圖片驗證碼

    Java仿12306圖片驗證碼

    這篇文章主要為大家詳細介紹了Java仿12306的圖片驗證碼的相關(guān)資料,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-04-04
  • Springboot?application.yml配置文件拆分方式

    Springboot?application.yml配置文件拆分方式

    這篇文章主要介紹了Springboot?application.yml配置文件拆分方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-05-05
  • java實現(xiàn)附件預(yù)覽(openoffice+swftools+flexpaper)實例

    java實現(xiàn)附件預(yù)覽(openoffice+swftools+flexpaper)實例

    本篇文章主要介紹了java實現(xiàn)附件預(yù)覽(openoffice+swftools+flexpaper)實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下。
    2016-10-10

最新評論

日土县| 偏关县| 龙江县| 循化| 余江县| 慈利县| 长乐市| 吉安市| 牙克石市| 浮山县| 汉寿县| 张北县| 南溪县| 司法| 水富县| 晋江市| 会昌县| 修文县| 昔阳县| 如皋市| 西平县| 河源市| 镇坪县| 西丰县| 霞浦县| 安远县| 恩平市| 普定县| 博客| 沧源| 遵化市| 玉田县| 普陀区| 宝山区| 湖口县| 平潭县| 富源县| 福鼎市| 辰溪县| 手机| 读书|