zoukankan      html  css  js  c++  java
  • maven编译后复制到目标位置

    maven对项目进行打包之后,可以将打包好的jar和某些资源文件复制到指定位置,例如你的项目结构是services父项目下有个子项目,service-1,它在打包之后,希望把jar和templates文件夹复制到父项目services的target目录,这就可以使用maven的两个插件来完成。

    maven-dependency-plugin

    编译之后,将当前项目的jar复制到某个目录下

     <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
         <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>${project.artifactId}</artifactId>
                                <version>${project.version}</version>
                            </artifactItem>
                        </artifactItems>
                        <outputDirectory>../target</outputDirectory>
                        <stripClassifier>true</stripClassifier>
                        <stripVersion>true</stripVersion>
                    </configuration>
                </execution>
         </executions>
    </plugin>
    

    maven-resources-plugin

    将资源目录resources下的某些文件,复制到上一级目录的templates下

    <plugin>
     <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>../target/templates</outputDirectory>
                    <resources>
                        <resource>
                            <directory>${basedir}/templates</directory>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    这两个插件在多级项目中,使用的很多,比如,你的多层项目都是一个SPI,这些SPI放在一起打一下镜像,对外提供服务,你就可以使用这两个插件来将它们的jar输出到父目录下。

  • 相关阅读:
    legend2---开发日志8(thinkphp和vue如何配合才能达到最优)
    英雄联盟:英雄台词翻译(我用双手成就你的梦想。)
    js插件---bootstrap插件daterangepicker是什么
    js插件---bootstrap-datepicker.js是什么
    ORDER BY RAND()
    Boost.Asio c++ 网络编程翻译(26)
    3Sum Closest
    hdu3480二维斜率优化DP
    MySQL Study之--Mysql无法启动“mysql.host”
    于PsIsSystemThread无论是在线程系统线程标识获得
  • 原文地址:https://www.cnblogs.com/lori/p/15498051.html
Copyright © 2011-2022 走看看