简体   繁体   English

自定义 spring 引导配置文件未在 IntelliJ 中激活

[英]Custom spring boot profiles not getting activated in IntelliJ

I am trying to create spring boot profiles for dev, ct, e2e and prod.我正在尝试为 dev、ct、e2e 和 prod 创建 spring 引导配置文件。 I am using application-*.yml files to provide the profile specific settings.我正在使用 application-*.yml 文件来提供特定于配置文件的设置。 I am able to activate the ct and prod profile successfully but I cannot activate the dev and e2e profiles.我能够成功激活 ct 和 prod 配置文件,但无法激活 dev 和 e2e 配置文件。

I have only observed this problem in IntelliJ.我只在 IntelliJ 中观察到这个问题。 Is this a bug in IntelliJ or am I missing something?这是 IntelliJ 中的错误还是我遗漏了什么?

I am currently using IntelliJ Community Edition 2020.1 version.我目前使用的是 IntelliJ Community Edition 2020.1 版本。 I have tried activating the profile from application.yml, from VM options and from Program Args from within IntelliJ but no luck.我尝试从 application.yml、VM 选项和 IntelliJ 中的 Program Args 激活配置文件,但没有成功。 Strangely even the console log gets stuck after printing the spring boot logo.奇怪的是,在打印 spring 引导徽标后,甚至控制台日志也卡住了。 Below is the log snippet:以下是日志片段:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.0.RELEASE)

After this no log is printed.在此之后没有打印日志。 Again: this only happens for dev, e2e or other profile names, ct and prod work just fine.同样:这只发生在 dev、e2e 或其他配置文件名称上,ct 和 prod 工作得很好。

The issue was due to incorrect configuration in logback-spring.xml.该问题是由于 logback-spring.xml 中的配置不正确造成的。 There was no appender configured for the custom profile and hence the logs were not being written to console.没有为自定义配置文件配置附加程序,因此日志没有写入控制台。 The app was correctly getting activated, only the logs were not being printed.该应用程序已正确激活,只是未打印日志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM