• windows环境cmd下执行jar


    项目目录结构

    一,在pom.xml文件里添加配置

     1 <build>
     2         <plugins>
     3             <plugin>
     4                 <groupId>org.apache.maven.plugins</groupId>
     5                 <artifactId>maven-jar-plugin</artifactId>
     6                 <configuration>
     7                     <archive>
     8                         <manifest>
     9                             <!--要执行的main方法-->
    10                             <mainClass>com.topsec.ticifs.graph.Main</mainClass>
    11                             <addClasspath>true</addClasspath>
    12                             <classpathPrefix>../lib/</classpathPrefix>
    13                             <useUniqueVersions>false</useUniqueVersions>
    14                         </manifest>
    15                     </archive>
    16                 </configuration>
    17             </plugin>
    18 
    19             <plugin>
    20                 <groupId>org.apache.maven.plugins</groupId>
    21                 <artifactId>maven-dependency-plugin</artifactId>
    22                 <executions>
    23                     <execution>
    24                         <id>copy-dependencies-lib</id>
    25                         <phase>package</phase>
    26                         <goals>
    27                             <goal>copy-dependencies</goal>
    28                         </goals>
    29                     </execution>
    30                 </executions>
    31             </plugin>
    32 
    33             <plugin>
    34                 <groupId>org.apache.maven.plugins</groupId>
    35                 <artifactId>maven-assembly-plugin</artifactId>
    36                 <configuration>
    37                     <descriptors>
    38                         <descriptor>src/assemble/standalone.xml</descriptor>
    39                     </descriptors>
    40                     <finalName>${project.artifactId}-${project.version}</finalName>
    41                     <appendAssemblyId>false</appendAssemblyId>
    42                 </configuration>
    43                 <executions>
    44                     <execution>
    45                         <id>make-assembly</id>
    46                         <phase>package</phase>
    47                         <goals>
    48                             <goal>single</goal>
    49                         </goals>
    50                     </execution>
    51                 </executions>
    52             </plugin>
    53             <plugin>
    54                 <groupId>org.apache.maven.plugins</groupId>
    55                 <artifactId>maven-surefire-plugin</artifactId>
    56                 <configuration>
    57                     <skip>true</skip>
    58                 </configuration>
    59             </plugin>
    60         </plugins>
    61     </build>

    二,assemble文件配置

     1 <assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     2           xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
     3           xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
     4     <id>standalone</id>
     5     <formats>
     6         <format>zip</format>
     7     </formats>
     8     <includeBaseDirectory>false</includeBaseDirectory>  设置为false,打包后的目录结构没有工程名  具体详见 :http://blog.51cto.com/supercharles888/981306
     9     <fileSets>
    10 
    11         <fileSet>
    12             <directory>${project.basedir}/target/dependency</directory>
    13             <outputDirectory>/lib</outputDirectory>
    14             <directoryMode>755</directoryMode>
    15             <fileMode>644</fileMode>
    16         </fileSet>
    17     </fileSets>
    18 
    19     <files>
    20         <!--要生成的jar包-->
    21         <file>
    22             <source>${project.basedir}/target/${project.artifactId}-${project.version}.jar</source>
    23             <outputDirectory>./apps/</outputDirectory>
    24             <destName>${project.artifactId}.jar</destName>
    25             <fileMode>644</fileMode>
    26         </file>
    27 
    28         <!--配置文件位置-->
    29         <file>
    30             <source>${project.basedir}/src/assemble/conf/config.properties</source>
    31             <outputDirectory>./conf/</outputDirectory>
    32             <destName>config.properties</destName>
    33             <fileMode>644</fileMode>
    34         </file>
    35      
    36     </files>
    37 
    38 </assembly>

    三,cmd运行jar包

    在cmd里运行java -jar

    1 C:UserssqyDesktopsticif测试	icifs-createTitan-1.0.3-SNAPSHOTapps>java -jar ticifs-createTitan.jar C:UserssqyDesktopsticif测试	icifs-createTitan-1.0.3-SNAPSHOT
    2 后面的C:UserssqyDesktopsticif测试	icifs-createTitan-1.0.3-SNAPSHOT为参数,也可以添加多个参数,用空格隔开
    3 参数长度:1 

    4 参数是: C:UserssqyDesktopsticif测试 icifs-createTitan-1.0.3-SNAPSHOT
  • 相关阅读:
    弱网测试(分析篇)
    弱网测试(资料罗列篇)
    2018年上半年系统分析师上午试题答案
    2018年上半年系统分析师案例分析答案
    测试执行过程注意事项
    略看操作系统
    Activity生命周期
    Android中的数据存储
    Android 进程生命周期 Process Lifecycle
    Android学习链接大放送
  • 原文地址:https://www.cnblogs.com/sqy123/p/9168516.html
Copyright © 2020-2023  润新知