https://img2020.cnblogs.com/blog/1101843/202010/1101843-20201029092119794-1182278230.jpg

支付宝

https://img2020.cnblogs.com/blog/1101843/202010/1101843-20201029091740174-1560674849.png

微 信

maven中profile的使用

项目有开发环境、测试环境、生产环境,不同的环境,数据源配置、日志文件配置会不一样,

每次我们将软件部署到不同的环境时,都需要修改相应的配置文件,这样来回修改,很容易出错,费时费力。

maven的profile功能就是为了解决这个问题。

pom.xml中配置如下:

<profiles>
        <!-- dev开发、debug联调、prd生产、test测试 -->
        <profile>
<!--不同环境Profile的唯一id-->
<id>dev</id>
<properties> <env>dev</env> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>debug</id> <properties> <env>debug</env> </properties> </profile> <profile> <id>debug-zb</id> <properties> <env>debug-zb</env> </properties> </profile> <profile> <id>test</id> <properties> <env>test</env> </properties> </profile> <profile> <id>prd</id> <properties> <env>prd</env> </properties> </profile> </profiles>

我们可以配置多个环境的文件,比如 :

src/main/resources/profiles/debug/resources/META-INF/jdbc-datasource.properties

src/main/resources/profiles/dev/resources/META-INF/jdbc-datasource.properties

 

 

具体 请百度。

 

 

 

Spring Boot - Profile不同环境配置

posted @ 2020-02-21 09:35  huangwanlin  阅读(771)  评论(0编辑  收藏  举报
Copyright 2012-2021 林云希科技有限责任公司