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输出到父目录下。
「其他文章」
- java~Optional语法糖
- Java~公用包中如何加载资源文件
- [email protected]一切为了可扩展性
- rsa~对接第三方rsa问题排查
- keycloak~自定义directgrant直接认证
- java~RMI引起的log4j漏洞
- k8s~Endpoints的使用之负载均衡
- keycloak~uma远程资源授权对接asp.net core
- es~存储部分字段
- maven编译后复制到目标位置
- keycloak~缓存的使用
- keycloak~授权功能的使用
- java~并行计算~大集合的并行处理
- keycloak~使用JDBC_PING实现k8s里的高可用
- keycloak~为认证提供者添加配置项
- skywalking的介绍
- springboot~disruptor异步队列
- keycloak~自定义rest接口
- springcloud~feign POST form-url-encoded data
- js~ajax获取后端HTTP状态的几种情况