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输出到父目录下。

  • 相关阅读:
    python3 socketserver服务端
    python3 组合的用法
    python3 面向对象高级一些的
    python3 继承原理
    python3 对象之间的交互
    hadoop配置、运行错误总结
    Hadoop配置项整理(mapred-site.xml)
    Hadoop配置项整理(core-site.xml)
    Hadoop配置项整理(hdfs-site.xml)
    Linux Shell 按Tab键不能补全
  • 原文地址:https://www.cnblogs.com/lori/p/15498051.html
Copyright © 2011-2022 走看看