• maven 打包的几种方式


    • 打jar包独立依赖
    <plugins>
                <!--      配置打包,并配置MainClass, 但不将依赖包打包,会出现找不到依赖的异常    -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <!--   MANIFEST.MF 中 Class-Path -->
                                <classpathPrefix>lib/</classpathPrefix>
                                <mainClass>indi.cyh.EurekaServer</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <!--      配置依赖包      -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>copy-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>
                            <configuration>
                                <!--              将依赖包打包至target下的lib目录              -->
                                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
    • 打jar包所有依赖都在jar包(spring框架下有问题)
    <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>indi.cyh.EurekaServer</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    
    • 打jar包所有依赖都在jar包(spring)
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    
  • 相关阅读:
    awk 字符串连接操作(字符串转数字,数字转字符串)
    Jenkins配置自动发送邮件,成功!
    可嵌入到网页的实用查询代码
    Windows中打开和关闭FSO文件读写权限的方法
    网站项目模型及业务流程分析
    2个JS版的MD5加密脚本
    申请@msn.com的邮箱最新网址
    成功激励格言精选
    随机切换广告图片
    译自MSDN非常详细的IMG,IFRAME的属性参考手册
  • 原文地址:https://www.cnblogs.com/cyh1282656849/p/15939142.html
Copyright © 2020-2023  润新知