zoukankan      html  css  js  c++  java
  • Java 打包

    1、maven update 项目

        选择Java项目,右键--maven -- update Maven Dependencies--OK

    2、打包前工程配置

    Following are the steps which I followed to resolve this issue:

    1. Create a resources folder in your src/main(ie src/main/resources)
    2. Create a META-INF folder in your src/main/resources
    3. Make MANIFEST.MF, spring.handlers and spring.schemas files under src/main/resources/META-INF.
    4. Paste the following in plugins section of your pom.xml
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-shade-plugin</artifactId>
     <version>1.4</version>
     <executions>
      <execution>
       <phase>package</phase>
           <goals>
              <goal>shade</goal>
           </goals>
       <configuration>
        <transformers>
         <transformer
       implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
          <mainClass> com.company.project.Main </mainClass>
         </transformer>
         <transformer
          implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
          <resource>META-INF/spring.handlers</resource>
         </transformer>
         <transformer
          implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
         <resource>META-INF/spring.schemas</resource>
         </transformer>
        </transformers>
        <shadedArtifactAttached>true</shadedArtifactAttached>
        <!-- optional -->
        <shadedClassifierName>executable</shadedClassifierName>
         </configuration>
       </execution>
      </executions>
    </plugin>

    (参考)http://www.cnblogs.com/lhj588/archive/2012/03/23/2414318.html

    3、打包

       cmd 

       cd  Java项目跟目录下。

       maven clean

       maven package

    4、java -jar  打包好的Jar包, (运行程序)

        

  • 相关阅读:
    CCF模拟题 窗口
    CSUOJ 1541 There is No Alternative
    MySQL数据库优化的八种方式(经典必看)
    PHP面向对象-----魔术方法
    PHP面向对象(OOP)----分页类
    2017最新PHP初级经典面试题目汇总(下篇)
    2017最新PHP经典面试题目汇总(上篇)
    原型模式
    适配器模式
    策略模式
  • 原文地址:https://www.cnblogs.com/lhj588/p/2414341.html
Copyright © 2011-2022 走看看