本篇和大家分享的是springboot打包并结合shell脚本命令部署 , 重点在分享一个shell程序启动工具,希望能便利工作 。
- profiles指定不同环境的配置
- maven-assembly-plugin打发布压缩包
- 分享shenniu_publish.sh程序启动工具
- linux上使用shenniu_publish.sh启动程序
文章插图
profiles指定不同环境的配置通常一套程序分为了很多个部署环境:开发,测试,uat,线上 等,我们要想对这些环境区分配置文件,可以通过两种方式:
- 通过Application.yml中编码指定 profile.active=uat 方式指定
- 通过mvn中profiles来区分不同环境对应的配置文件夹,人工可以手动在idea勾选生成不同环境的包(推荐)
<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>
节点粗解:- id: 用来指定不同环境配置文件所在的目录,如下我这里:
文章插图
- properties: 该节点中的节点是可作为参数传递给其他配置文件,如我这里的package-name节点值就可以在另外的assembly.xml或者shell脚本文件中通过${package-name}获取到,如下:
文章插图
- activeByDefault: 指定默认环境配置文件夹
<plugin><groupId>org.Apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>2.6</version><configuration><archive><addMavenDescriptor>false</addMavenDescriptor><manifest><addClasspath>true</addClasspath><classpathPrefix>lib/</classpathPrefix><mainClass>${scripts_bootMain}</mainClass></manifest></archive><!--打包排除项--><excludes><exclude>**/*.yml</exclude><exclude>**/*.properties</exclude><exclude>**/*.xml</exclude><exclude>**/*.sh</exclude></excludes></configuration><executions><execution><id>make-a-jar</id><phase>compile</phase><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>2.4</version><!-- The configuration of the plugin --><configuration><!-- Specifies the configuration file of the assembly plugin --><descriptors><descriptor>${project.basedir}/src/main/assembly/assembly.xml</descriptor></descriptors></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>single</goal></goals></execution></executions></plugin>
值得注意的地方如下几点:- mainClass节点: 用来指定启动main函数入口类路径,如这里的:com.sm.EurekaServerApplication
推荐阅读
- 六旬山口百惠近照!穿黑色羽绒服仍眉眼清秀,老公三浦友陪伴在侧
- 《狂飙》中的六大恶人,高启强差点上不了榜,第一名非他莫属
- 网站流量异常下降,六大方面排查原因及解决方案
- 2024 年 Linux 和开源的六大趋势预测
- 毁掉汪峰,刀郎用了19年,而东山再起,汪峰只用了两天
- 蚕丝被内胆脏了怎么清洗 蚕丝被一般用几年就不能用了
- 六位香港艺人落魄转行,卖保险,卖鱼蛋,最佳女配成了按摩技师!
- 龙芯中科是国企,哪个上市公司的控股股东是中科院
- 小杨哥签约重量级网红!一年销售10几亿,还将厦门分公司交给对方
- 亚航航空科技 中国第一家低成本航空公司