• Maven打包程序


    1、src/main目录下建立scritps、config、assembly目录
    scritps:存放脚本文件如批处理
    assembly:打包配置文件
     
    2、assembly目录下建立package.xml
     1 <assembly>
     2   <id>bin</id>
     3   <!-- 最终打包成一个用于发布的zip文件 -->
     4   <formats>
     5     <format>zip</format>
     6   </formats>
     7 
     8   <!-- Adds dependencies to zip package under lib directory -->
     9   <dependencySets>
    10     <dependencySet>
    11       <!-- 第三方jar不要解压,打包进zip文件的lib目录 -->
    12       <useProjectArtifact>false</useProjectArtifact>
    13       <outputDirectory>lib</outputDirectory>
    14       <unpack>false</unpack>
    15     </dependencySet>
    16   </dependencySets>
    17 
    18   <fileSets>
    19     <!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
    20     <fileSet>
    21       <directory>${project.basedir}</directory>
    22       <outputDirectory>/</outputDirectory>
    23       <includes>
    24         <include>README*</include>
    25         <include>LICENSE*</include>
    26         <include>NOTICE*</include>
    27       </includes>
    28     </fileSet>
    29 
    30     <!-- 把项目的配置文件,打包进zip文件的config目录 -->
    31     <fileSet>
    32       <directory>${project.basedir}srcmain
    esources</directory>
    33       <outputDirectory>conf</outputDirectory>
    34       <includes>
    35         <include>*.properties</include>
    36       </includes>
    37     </fileSet>
    38 
    39     <!-- 把项目的脚本文件目录中的启动脚本文件,打包进zip文件的跟目录 -->
    40     <fileSet>
    41       <directory>${project.basedir}srcmainscripts</directory>
    42       <outputDirectory></outputDirectory>
    43       <includes>
    44         <include>run.*</include>
    45       </includes>
    46     </fileSet>
    47 
    48 49     <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
    50     <fileSet>
    51       <directory>${project.build.directory}</directory>
    52       <outputDirectory></outputDirectory>
    53       <includes>
    54         <include>*.jar</include>
    55       </includes>
    56     </fileSet>
    57   </fileSets>
    58 </assembly>

    3、修改pom.xml文件,增加plugin

     1   <plugin>
     2         <groupId>org.apache.maven.plugins</groupId>
     3          <artifactId>maven-jar-plugin</artifactId>
     4          <configuration>
     5              <archive>
     6                 <manifest>
     7                     <addClasspath>true</addClasspath>
     8                      <classpathPrefix>lib/</classpathPrefix>
     9                      <mainClass>程序main函数所在类的全类名</mainClass>
    10                   </manifest>
    11                </archive>
    12      </configuration>
    13   </plugin>
    14 
    15 
    16     <plugin>
    17       <groupId>org.apache.maven.plugins</groupId>
    18       <artifactId>maven-assembly-plugin</artifactId>
    19       <version>2.4</version>
    20       <configuration>
    21        <descriptors>
    22                <descriptor>src/main/assembly/package.xml</descriptor>
    23              </descriptors>
    24        </configuration>
    25        <executions>
    26               <execution>
    27               <id>make-assembly</id>
    28                <phase>package</phase>
    29               <goals>
    30                   <goal>single</goal>
    31               </goals>
    32            </execution>
    33       </executions>
    34  </plugin>
  • 相关阅读:
    MYSQL数据丢失讨论【转】
    MySQL 5.6 新功能之 Index Condition Pushdown (ICP)
    MySQL Binlog 【ROW】和【STATEMENT】选择
    MySQL open_files_limit相关设置
    Python颜色输出和random的学习
    Python 之 【二进制、十进制、八进制、十六进制 】之间的转换【转】
    初识 MySQL 5.5 新功能、参数
    Oracle Inventory关键词解释
    plsql 输出当月的所有日期
    ORA29279: SMTP permanent error: 550 XXX@XX.com... No such user
  • 原文地址:https://www.cnblogs.com/zengguoyu/p/4882265.html
Copyright © 2020-2023  润新知