Intellij Idea Profiles属性已过时,适用于Spring-Kafka的是properties.yml

mv1qrgav  于 2022-11-21  发布在  Spring
关注(0)|答案(3)|浏览(126)


我正在Spring Kafka MS中配置application.yml文件,我收到了profiles属性已过时的通知。此“profiles”属性已过时

spring:
  profiles:
    active: docker
---

建议的解决方案是使用以下语法:

spring:
  config:
    activate:
      on-profile: docker
---

但在日志中,我可以看到"没有活动的配置文件集:
我使用的是Java 11和Spring 2.6.2 IDEA:IntelliJ 2022.1(终极版)

: No active profile set, falling back to default profiles: default
ax6ht2ek

ax6ht2ek2#

我想你是混淆了spring.profiles.active(这是不赞成的https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html#application-properties.core.spring.profiles.active)与yaml文件中的yaml文档中的spring.profiles

spring:
  profiles:
    active: dev
---
spring:
  config:
    activate:
      on-profile: dev
  kafka:
    template:
      default-topic: devTopic
...
---
spring:
  config:
    activate:
      on-profile: prod
  kafka:
    template:
      default-topic: prodTopic
...

spring:
  profiles:
    active: local
---
spring:
  profiles: dev # deprecated
  kafka:
    template:
      default-topic: devTopic
...
---
spring:
  profiles: prod # deprecated
  kafka:
    template:
      default-topic: prodTopic
...

智能理念:

eyh26e7m

eyh26e7m3#

您需要更改文件名。编辑属性名称到应用程序。因此,properties.yml -〉refactor-〉rename-〉application.yml

相关问题