SpringBoot——多环境打包

一、整合多环境打包功能

1.1、修改pom.xml文件

<profiles>
	<profile>
		<id>dev</id>
		<properties>
			<env>dev</env>
		</properties>
		<activation>
			<activeByDefault>true</activeByDefault>
		</activation>
	</profile>
	<profile>
		<id>test</id>
		<properties>
			<env>test</env>
		</properties>
	</profile>
	<profile>
		<id>prod</id>
		<properties>
			<env>prod</env>
		</properties>
	</profile>
</profiles>

<build>
	<resources>
		<resource>
			<filtering>true</filtering>
			<directory>src/main/resources</directory>
		</resource>
	</resources>
	<plugins>
		<plugin>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-maven-plugin</artifactId>
			<configuration>
				<mainClass>com.sz.qzxkj.SipoEurekaPlugin</mainClass>
			</configuration>
			<executions>
				<execution>
					<goals>
						<goal>repackage</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

1.2、application.properties进行环境拆分

在这里插入图片描述

1.3、设置使用指定环境的占位符

在这里插入图片描述

1.4、Maven打包方式

mvn package -Dmaven.test.skip=true -P prod -f pom.xml

二、通过命令行部署并设置属性值

2.1、部署jar包命令

nohup java -XXX.jar &  // 启动命令
java -jar xxx.jar --server.port=8888 // 设置端口
SpringApplication.setAddCommandLineProperties(false); // 屏蔽命令行访问属性的设置
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值