【问题标题】:Ballerina V 1.0 - Get configuration value from fileBallerina V 1.0 - 从文件中获取配置值
【发布时间】:2019-10-06 21:07:17
【问题描述】:

我正在尝试使用 ballerina V 1.0 从文件中获取配置值。 配置文件如下:

我正在尝试将 test.bal 文件中的值打印为;

io:println(config:getAsString("student.jdbc.username"));

当我在 ballerina.conf 文件中提供配置值时,它在以下命令中运行良好。

芭蕾舞演员运行.\test.bal

现在我需要从另一个文件 (testConf.conf) 中读取配置 我尝试了下面的命令来运行我的项目,但它没有像预期的那样采用配置值。

芭蕾舞演员运行.\test.bal -config testConf.conf

芭蕾舞演员运行.\test.bal -c testConf.conf

芭蕾舞演员运行 .\test.bal -Bballerina.conf=.\testConf.conf

还尝试使用上述命令使用 .toml 文件,但没有成功。

从给定文件(ballerina.conf 除外)读取配置的命令是什么?

【问题讨论】:

    标签: ballerina


    【解决方案1】:

    使用 Ballerina v1.0,自定义配置文件路径如下:

    ballerina run .\test.bal --b7a.config.file=path/to/conf/file/file-name.conf

    请参考下面的例子以及它是如何执行的。

    https://v1-0.ballerina.io/learn/by-example/config-api.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多