> 文章列表 > SpringCloud 项目如何方便 maven 打包以及本地开发

SpringCloud 项目如何方便 maven 打包以及本地开发

SpringCloud 项目如何方便 maven 打包以及本地开发

一、背景

springcloud-alibaba ,使用 nacos 做配置中心,maven 作为构建工具。为了防止 test 、prod 环境配置文件覆盖问题,使用 mvn -P 命令。

二、项目 pom 文件

1. 利用 resources 标签来指定目录,build > resources 标签:

 

2. 定义 profile ,用来接受 mvn -P 传参:

 

3. 引入  maven-resources-plugin 来处理 resouces ,build > plugins > plugin 标签:

 

resources目录中, test 目录下的 bootstrap.yml 指向测试的 nacos,prod 目录下bootstrap.yml 配置的是生产的 nacos。

三、Jenkins 打包

定义变量 env

 

 这样就可以根据用户选择test/prod 来打对应的包即可:选择 test 环境时, 就会将  test/bootstrap.yml 打包进去。

 


如果觉得还不错的话,关注、分享、在看, 原创不易,且看且珍惜~

 

操作系统大全