![](https://csdnimg.cn/release/download_crawler_static/88622501/bg1.jpg)
SpringBoot项目打包+shell脚本部署实践,太有用了
!
通常一套程序分为了很多个部署环境:开发,测试,uat,线上
等,我们要想对这些环境区分配置文件,可以通过两种方式:
通过application.yml中编码指定 profile.active=uat 方式指定
通过mvn中profiles来区分不同环境对应的配置文件夹,人工可以手动在idea
勾选生成不同环境的包(推荐)
这里我们要讲的是第二种,首先在mvn中配置如下内容:
<profiles>
<profile>
<id>node</id>
<properties>
<!--传递给脚本的参数值-->
<activeProfile>node</activeProfile>
<package-name>${scripts_packageName}</package-name>
<boot-main>${scripts_bootMain}</boot-main>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>node1</id>
<properties>
<activeProfile>node1</activeProfile>
<package-name>${scripts_packageName}</package-name>
<boot-main>${scripts_bootMain}</boot-main>
</properties>
</profile>
<profile>
<id>node2</id>
<properties>
<activeProfile>node2</activeProfile>
<package-name>${scripts_packageName}</package-name>
<boot-main>${scripts_bootMain}</boot-main>
</properties>
</profile>
</profiles>
节点粗解: