ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

Spring Boot java -jar --spring.profiles.active=dev 失效问题

2026/9/17 5:38:05 拓冰建站 浏览量
Spring Boot java -jar --spring.profiles.active=dev 失效问题

之前动态部署修改配置文件的情况不多,所以也没注意过,这个问题今天困扰了好久,经过多方查询后得到了解决办法

直接上代码

<profiles><profile><!-- 本地开发环境 --><id>dev</id><properties><profiles.active>dev</profiles.active></properties><activation><activeByDefault>true</activeByDefault></activation></profile><profile><!-- 生产环境 --><id>prod</id><properties><profiles.active>prod</profiles.active></properties></profile><profile><!-- 测试环境 --><id>test</id><properties><profiles.active>test</profiles.active></properties></profile><profile><!-- local环境 --><id>local</id><properties><profiles.active>local</profiles.active></properties></profile></profiles><build><resources><resource><directory>src/main/resources</directory><filtering>true</filtering><!-- 资源根目录排除各环境的配置,防止在生成目录中多余其它目录 --><excludes><exclude>test/*</exclude><exclude>prod/*</exclude><exclude>dev/*</exclude></excludes></resource><resource><directory>src/main/resources/${profiles.active}</directory></resource></resources></build>

yml中的配置
在这里插入图片描述