- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
好的,我已经尝试了以下方法,但并没有产生我想要的效果。我有一个 reference.conf
指定相对于前缀的文件系统位置,看起来有点像这样:
// reference.conf
myapp {
// The dummy path makes the error message easy to diagnose
s3.prefix = "s3://environment/variable/S3_PREFIX/missing"
s3.prefix = ${?S3_PREFIX}
file1 = ${myapp.s3.prefix}"/file1.csv"
file2 = ${myapp.s3.prefix}"/file2.csv"
// ...
}
application.conf
文件看起来或多或少是这样的:
// application.conf
myapp.s3.prefix = "s3://some-bucket/some/path/to/the/files"
myapp.file2 = "s3://some-other-bucket/some/path/file2.csv"
ConfigFactory.load()
, 从 :
reference.conf
文件,执行替换,并生成 Config
对象,其中:myapp.s3.prefix = "/environment/variable/S3_PREFIX/missing"
myapp.file1 = "/environment/variable/S3_PREFIX/missing/file1.csv"
myapp.file2 = "/environment/variable/S3_PREFIX/missing/file2.csv"
. application.conf
文件并生成 Config
对象,其中:library.prefix = "/some/path/to/the/files"
myapp.file2 = "s3://some-other-bucket/some/path/file2.csv"
. reference.conf
对象作为后备。由此产生的 Config
因此,对象具有:library.prefix = "s3://some-bucket/some/path/to/the/files"
(如 application.conf
) library.file1 = "s3://environment/variable/S3_PREFIX/missing/file1.csv"
(如 reference.conf
)。 library.file2 = "s3://some-other-bucket/some/path/file2.csv"
(如 application.conf
)。 reference.conf
指定相对于根目录的默认路径,并允许
的任意组合两者 这些:
application.conf
中的默认根目录, 这样默认的相对路径来自 reference.conf
从那里抬头。 application.conf
中任何单个文件的路径,因此应用程序可以使用不在根目录中的路径。 // reference.conf
myapp {
// The dummy path makes the error message easy to diagnose
s3.prefix = "s3:/environment/variable/S3_PREFIX/missing"
s3.prefix = ${?S3_PREFIX}
file1 = "file1.csv"
file2 = "file2.csv"
// ...
}
// application.conf
myapp.s3.prefix = "s3://some-bucket/some/path/to/the/files"
myapp.file2 = "s3://some-other-bucket/some/path/file2.csv"
// The Java code for using the config must append prefix and file location,
// and needs to have smarts about relative vs. absolute paths.
final Config CONF = ConfigFactory.load();
String getS3URLFor(String file) {
String root = CONF.getString("myapp.s3.prefix");
String path = CONF.getString("myapp." + file);
return relativeVsAbsoluteSensitiveMerge(root, path);
}
String relativeVsAbsoluteSensitiveMerge(String root, String path) {
if (isAbsoluteReference(path)) {
return path;
} else {
return root + "/" + path;
}
}
boolean isAbsoluteReference(String path) {
// ...
}
最佳答案
您可以先解析,然后解析:
ConfigFactory.parseResources(s"file.conf")
.withValue("myKey", ConfigValueFactory.fromAnyRef("newValue"))
.resolve()
关于typesafe-stack - 类型安全配置 : best pattern for overriding substitutions in later settings?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27160840/
2019-07-04:更新 结束使用 options: env: 不完美,因为在构建步骤中不允许变量,但至少涵盖了环境。 问题 GCP Cloud build不替换 substitutions
我正在使用 NSubstitute。我必须伪造一个类,无法挖掘出 Substitute.For() 的区别和 Substitute.ForPartsOf .我已经阅读了文档,但不明白两者的行为不同。
我正在尝试在 Agda 中使用等递归类型对按推值调用 lambda 演算进行编码。所以我用最多n个自由值类型变量相互定义值类型和计算类型(我只需要用值类型代替等递归类型)如下(这只是一个片段)。 da
有没有办法用s///同时进行替换?例如,如果我有一个带有1、2、3等数字的字符串,并且我想用“tom”代替1,用“mary”代替2,用“jane”代替3,等等? my $a = "1323131323
我有一个使用模板的 Jav::String 类。 class String { String(); String(std::size_t); template String(co
考虑以下 C99 结构,以灵活的数组成员结尾: struct hdr { size_t len; size_t free; char buf[]; }; 例如, len 可以通过这样
我有一个范围,包含数值和空白单元格。一些数值将以 * 作为后缀。 10* 5 7 9 25* 10 当我执行 SUM(A1:A8) 时,我得到 5+7+9+10 = 31 的结果,即所需的输出。
有没有办法一次交换多个字符串实例而不嵌套? 例如,假设我想从字符串中删除以下值的所有实例: 目标 沃尔玛 简历 输入字符串: “我去了 Target 而不是沃尔玛,但我真的很想去 CVS” 输出字符串
我在 Vim 的 substitute 中遇到了一个行为。 - 我不能的命令 真正遵循: 给定以下包含 && 的代码行我想要的序列 替换 &&与 &&和换行符: return a && b 在我的第一
为了说明我的问题,请使用以下简单示例。 我希望能够将“替换”和“那个”之间的任何文本替换为“完成”。例如,以下两个字符串: blah blah blah replace this and that b
我之前问过一个关于How to take in text/character argument without quotes的问题.在我在那个问题中提供的场景中,参数的数量是固定的,所以我在函数定义中
我正在尝试将一些 Selenium HTML 测试转换为使用 WebDriver 2.0 框架。根据网站 (http://seleniumhq.org/docs/03_webdriver.html),
那应该很容易...如何在下图中的标题中以粗体显示 i (=1)(仅调整参数 main)? i <- 1 plot(0~0, main=substitute(bold("foo"~i.~"bar"),
那应该很容易...如何在下图中的标题中以粗体显示 i (=1)(仅调整参数 main)? i <- 1 plot(0~0, main=substitute(bold("foo"~i.~"bar"),
这是一个现有的通用 css 规则(原始文件): .caption-top { color: red; } 这是示意图,因为在现实生活中,我需要根据上下文将 .caption-top 选择器变成其他
这是我的代码: $(".tooltip").live('click', function() { var texte = $('#tiptip_content').text(); $(
我需要帮助将变量子化为正则表达式 这条线工作正常: subject = subject.replace(//g, emoticons[1]); 我需要为变量切换单词“Smile”。 我尝试了一些不同的
我读了一篇摘要,其中在谈到继承时总是使用“替代原则”的定义。但并没有解释这个原理的含义。 这个原理是什么? 谢谢。 最佳答案 意思很简单:子类必须遵守父类(super class)设定的契约。 如果你
我有一个变量,它是一个 url,我想在 bash 中替换该 url 的一部分,但我一直收到“错误的替换” URL="http://hostname/project/branches/Old_Branc
#!/bin/bash jobname="job_201312161447_0003" jobname_pre=${jobname:0:16} jobname_post=${jobname:17} 这
我是一名优秀的程序员,十分优秀!