• 【Java】【maven】运行jar的2中方式和打包方式


    运行jar方式

    1、java -jar ***.jar

    2、java -cp ***.jar main方法类全路径,例如:java -cp test.jar com.xiaostudy.Test

    打包方式

    1、原生打包方式

     

     

     

     

     2、maven打包方式

     

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>reference.conf</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- 使用maven-assembly-plugin插件打包 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>com.xiaostudy.Test</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
    
        </plugins>
    </build>

     

  • 相关阅读:
    uni-app、VUE、微信小程序之异同
    git学习之通俗易懂篇(四)
    css学习之-----flex布局
    git学习之通俗易懂篇(三)
    git学习之通俗易懂篇(二)
    防止非法登录
    MVC 路由配置
    C# 跨线程调用控件
    【推荐】gitee 的使用,sts4公钥私钥的配置,
    查看java的springboot的内存占用
  • 原文地址:https://www.cnblogs.com/xiaostudy/p/14492625.html
Copyright © 2020-2023  润新知