如何在IntelliJ for Gradle任务中设置环境变量 [英] How to set environment vars in IntelliJ for Gradle tasks
问题描述
通过环境变量(例如 SPRING_PROFILES_ACTIVE
)将Spring配置文件传递给 gradle bootRun
的最简单方法是(对我而言) ),在命令行上运行。
与应用程序配置不同,gradle任务的配置不提供环境变量的输入。由于虚拟机选项没有像我看起来那样被拾取,所以我无法从IDE运行这些任务。
我知道,我可以使用envvar设置启动IntelliJ,但这看起来相当麻烦。
所以我需要的是IntelliJ的<系统是linux,intellij 14.项目在问题是使用springboot,我想从IntelliJ运行中的 main
移动到 springloaded + bootRun $因为IntelliJ并不完全理解gradle文件,因此隐藏了错误。
compileGroovy
解决方案在 bootRun
(或其他)中提供 System.properties
)任务。 bootRun.systemProperties = System.properties
通过这种方式,我们可以在IntelliJ VM Options 中设置,例如 -Dspring.profiles.active = dev
。
the easiest way to pass spring profiles to gradle bootRun
is (for me) by environment variable (e.g. SPRING_PROFILES_ACTIVE
), when run on commandline.
Unlike the Application configurations, the config for gradle tasks does not provide an input for environment variables. And as VM options don't get picked up either as it seems, I can not run those tasks from the IDE.
I am aware, that I could start IntelliJ with the envvar set, but this seems rather cumbersome.
So what I need is the IntelliJ pendant for SPRING_PROFILES_ACTIVE=dev,testdb gradle bootRun
, unless there is a good reason, they have left this out.
System is linux, intellij 14. The project in question is using springboot and I want to move over from running main
in IntelliJ to running with springloaded+bootRun
and separate compileGroovy
calls as IntelliJ is not "understanding" the gradle file completely and therefor hides errors.
Make the System.properties
available in the bootRun
(or other) tasks.
bootRun.systemProperties = System.properties
This way we can set in IntelliJ VM Options like -Dspring.profiles.active=dev
.
这篇关于如何在IntelliJ for Gradle任务中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!