首页  

springboot Maven 多环境构建 profile     所属分类 maven 浏览量 5
spring.application.name = springreport
spring.profiles.active = @profiles.active@

@profiles.active@  maven编译构建时替换

pom.xml里定义 

关键配置 


<resource>
	<directory>src/main/resources</directory>
	<filtering>true</filtering>
</resource>



<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<profiles.active>dev</profiles.active>
			</properties>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
		</profile>

		<profile>
			<id>test</id>
			<properties>
				<profiles.active>test</profiles.active>
			</properties>
			<activation>
				<activeByDefault>false</activeByDefault>
			</activation>
		</profile>
		<profile>
			<id>pub</id>
			<properties>
				<profiles.active>pub</profiles.active>
			</properties>
			<activation>
				<activeByDefault>false</activeByDefault>
			</activation>
		</profile>
		
	</profiles>





mvn clean package     #默认激活 dev  ,activeByDefault 为 true 
mvn clean package -P test     # 激活 test 环境

上一篇     下一篇
Python f-string 格式化字符串字面量

python3 实用代码2

《走进我的交易室》精华笔记

springboot环境变量替换配置文件值