配置步骤
首先在application.yml中添加beetl模板支持和不同环境配置
# 热加载beetl支持
beetl:
resource-auto-check: true
# 多环境支持
spring:
profiles:
active: "@spring.active@"
main:
allow-bean-definition-overriding: true
在resource
目录下添加不同环境的application
文件
在文件中添加开发环境和部署环境的配置:例如数据库配置
本地开发环境配置
部署环境的配置:
紧接着修改pom.xml文件:
在<project></project>
标签中添加如下代码:
<!-- 开发,部署环境配置 -->
<profiles>
<profile>
<id>local</id>
<properties>
<spring.active>local</spring.active>
</properties>
<!-- 默认使用开发环境 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>online</id>
<properties>
<spring.active>online</spring.active>
</properties>
</profile>
</profiles>
更新pom文件。
效果展示:
最后就可以通过切换这个来打包发布了