IDEA中SpringBoot项目的yml多环境配置方式
SpringBoot的yml多环境配置
创建多个配置文件
application.yml #主配置文件 application-dev.yml #开发环境的配置 application-test.yml #测试环境的配置
在application.yml中添加多环境配置属性
spring: profiles: active: @profiles.active@
项目启动可能不会识别@,在pom.xml中设置filtering为true
<build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>**/*.*</include> </includes> </resource> </resources> </build>
在pom.xml中指定使用的配置
<profiles> <profile> <id>dev</id> <activation> <!-- 默认激活--> <activeByDefault>true</activeByDefault> </activation> <properties> <profiles.active>dev</profiles.active> </properties> </profile> <profile> <id>test</id> <properties> <profiles.active>test</profiles.active> </properties> </profile> </profiles>
到此即为配置完毕,在maven->profiles下勾选动态激活需要使用的配置,想使用哪个配置勾选即可,其余的配置勾除,最后启动项目使用的配置就是勾选的配置文件
参考文章:https://blog.csdn.net/github_36665118/article/details/130555496
到此这篇关于IDEA中SpringBoot项目的yml多环境配置的文章就介绍到这了,更多相关idea springboot多环境配置内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Java中ArrayList去除重复元素(包括字符串和自定义对象)
本文主要介绍了Java中ArrayList去除重复元素(包括字符串和自定义对象)的方法。具有很好的参考价值。下面跟着小编一起来看下吧2017-03-03springboot+thymeleaf打包成jar后找不到静态资源的坑及解决
这篇文章主要介绍了springboot+thymeleaf打包成jar后找不到静态资源的坑及解决,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2021-11-11springboot整合RabbitMQ 中的 TTL实例代码
TTL 是 RabbitMQ 中一个消息或者队列的属性,表明一条消息或者该队列中的所有消息的最大存活时间,单位是毫秒,这篇文章主要介绍了springboot整合RabbitMQ 中的 TTL,需要的朋友可以参考下2022-09-09
最新评论