java - Spring Boot + Gradle:运行单个测试时采用 VM 选项
问题描述
当我test
从 IntelliJ 运行 Gradle 任务时,我在“编辑配置”对话框中为所有测试设置 VM 选项和/或环境变量,它们可以工作。请参阅我的问题:如何在 Intellij IDEA 社区版本中为 gradle spring boot 项目设置 spring.config.location?
现在,如果我想运行一个测试,我必须:
- 运行测试,当然会失败
- 编辑配置以添加 VM 选项和/或环境变量
- 再次运行它
是否有某种方法可以配置 VM 选项和/或 env var,build.gradle
以便每个测试都自动获取?
PS:参数是-Dspring.profiles.active=...
and -Dspring.config.additional-location
。
解决方案
尝试在文件gradle.properties中设置系统属性,如下所示:
systemProp.spring.profiles.active=profileName
spring.config.additional-location=additionalLocation
另请参阅:https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_system_properties
推荐阅读
- python-3.6 - Argparse 帮助屏幕:在 SUB 解析器的可选参数上方显示所需参数
- javascript - 未执行 Google 地图信息窗口中 HTML 内容的 javascript
- ms-access - 更改附加到 ListBox 的 ADODB.Recordset 的光标位置是否保存?
- r - 在 R 中使用复杂的填充规则将向量重塑为更大的矩阵
- javascript - 使用 javascript 检查 css 文件中的选择器重复项
- git - 从已经在 PR 中的 PR 中排除提交
- mysql - SQL - 在 Mysql 中将一列拆分为两列
- c++ - 类成员重新排序
- c - 生成遵循特定分布的随机双打
- javascript - You Don't Know JS: Up & Going - 示例问题