欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

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

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

從pom的xsi中可以打開(kāi)描述pom的schema:

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

默認(rèn)的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)(包括繼承而來(lái)的屬性):

[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] ------------------------------------------------------------------------

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Spring Boot兩種配置文件properties和yml區(qū)別

    Spring Boot兩種配置文件properties和yml區(qū)別

    這篇文章主要為大家介紹了java面試中常見(jiàn)問(wèn)到的Spring Boot兩種配置文件properties和yml區(qū)別解答,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07
  • SpringBoot中實(shí)現(xiàn)Redis?Stream隊(duì)列的代碼實(shí)例

    SpringBoot中實(shí)現(xiàn)Redis?Stream隊(duì)列的代碼實(shí)例

    本文介紹了如何在Spring?Boot中使用Redis?Stream隊(duì)列進(jìn)行消息的生產(chǎn)和消費(fèi),涉及到的主要內(nèi)容包括添加Redis依賴、配置RedisTemplate、創(chuàng)建生產(chǎn)者和消費(fèi)者監(jiān)聽(tīng)器等,需要的朋友可以參考下
    2024-09-09
  • springboot運(yùn)行到dokcer中 dockerfile的場(chǎng)景分析

    springboot運(yùn)行到dokcer中 dockerfile的場(chǎng)景分析

    這篇文章主要介紹了springboot運(yùn)行到dokcer中 dockerfile,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-03-03
  • springboot下mybatis-plus開(kāi)啟打印sql日志的配置指南

    springboot下mybatis-plus開(kāi)啟打印sql日志的配置指南

    這篇文章主要給大家介紹了關(guān)于springboot下mybatis-plus開(kāi)啟打印sql日志的配置指南的相關(guān)資料,還介紹了關(guān)閉打印的方法,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2023-03-03
  • Java設(shè)計(jì)模式之中介模式

    Java設(shè)計(jì)模式之中介模式

    這篇文章主要介紹了Java設(shè)計(jì)模式之中介模式,中介模式(Mediator?Pattern),屬于行為型設(shè)計(jì)模式,目的是把系統(tǒng)中對(duì)象之間的調(diào)用關(guān)系從一對(duì)多轉(zhuǎn)變成一對(duì)一的調(diào)用關(guān)系,以此來(lái)降低多個(gè)對(duì)象和類之間的通信復(fù)雜性,需要的朋友可以參考下
    2023-12-12
  • 關(guān)于Maven依賴沖突解決之exclusions

    關(guān)于Maven依賴沖突解決之exclusions

    這篇文章主要介紹了關(guān)于Maven依賴沖突解決之exclusions用法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Java spring的三種注入方式詳解流程

    Java spring的三種注入方式詳解流程

    Spring框架由Rod Johnson開(kāi)發(fā),2004年發(fā)布了Spring框架的第一版。Spring是一個(gè)從實(shí)際開(kāi)發(fā)中抽取出來(lái)的框架,因此它完成了大量開(kāi)發(fā)中的通用步驟,留給開(kāi)發(fā)者的僅僅是與特定應(yīng)用相關(guān)的部分,從而大大提高了企業(yè)應(yīng)用的開(kāi)發(fā)效率
    2021-10-10
  • Spring bean的實(shí)例化和IOC依賴注入詳解

    Spring bean的實(shí)例化和IOC依賴注入詳解

    這篇文章主要介紹了Spring bean的實(shí)例化和IOC依賴注入詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-03-03
  • Gradle使用Maven倉(cāng)庫(kù)的方法

    Gradle使用Maven倉(cāng)庫(kù)的方法

    本篇文章主要介紹了Gradle使用Maven倉(cāng)庫(kù)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • 解析SpringBoot中使用LoadTimeWeaving技術(shù)實(shí)現(xiàn)AOP功能

    解析SpringBoot中使用LoadTimeWeaving技術(shù)實(shí)現(xiàn)AOP功能

    這篇文章主要介紹了SpringBoot中使用LoadTimeWeaving技術(shù)實(shí)現(xiàn)AOP功能,AOP面向切面編程,通過(guò)為目標(biāo)類織入切面的方式,實(shí)現(xiàn)對(duì)目標(biāo)類功能的增強(qiáng),本文給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-09-09

最新評(píng)論