profiles 配置详解

profiles 配置详解

@Profile (value = "pro" )

1,为什么要使用 profiles

在开发中,一般有两种环境

1,生产环境 [项目上线,客户在使用中,就是生产环境]

2,开发环境[就是开发环境,不解释]

有时候开发环境和生产环境的配置方法是不一样的,那么如何快速的切换呢,这里就要

使用 profiles 文件



2 ,使用方法

1,创建 application-developer.properties

server.port=8081

2,创建 application-product.properties

server.port=8082

3,修改 application.properties

#server.port=8080

spring.profiles.active=developer

4,运行测试

5,总结

在 application.properties 里面激活哪个文件就会使用哪个端口




3,去掉 application.properties 的运行方式

删除 application.properties

打包

使用 jar -jar 去运行

发布了529 篇原创文章 · 获赞 115 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq_39368007/article/details/105607767