如何解决是否可以将其他配置文件添加为Micronaut中的默认配置文件?
在Spring中,我可以使用以下内容包含具有非默认名称的配置文件:
public static void main(String[] args) {
/*
This allows us to add an additional configuration file to the default configuration.
By using the `spring.config.name` property,we can specify the order of property files to load from the `spring.config.location` that we specify on startup (if not specified,it assumes the default). This also respects profiles as well.
*/
ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(DirectconnectEdgeserviceApplication.class)
.properties("spring.config.name:application,secrets")
.build().run(args);
}
它使用Spring属性spring.config.name
指定将配置文件命名为application*
或secrets*
。
我可能可以导入io.micronaut.spring.context
并使用MicronautApplicationContext,但是我想知道是否可以在香草Micronaut中实现此目的?
解决方法
我可以在Micronaut中将其他配置文件恢复为默认设置吗?
是的。有很多方法可以做到这一点。一种常见的用法是使用micronaut.config.files
JVM系统属性来指向文件。
java -Dmicronaut.config.files="/path/to/someConfig.yml" myapp.jar
您还可以设置相应的OS环境变量:
export MICRONAUT_CONFIG_FILES=somefile.yml
更多信息,请访问https://docs.micronaut.io/2.1.1/guide/index.html#propertySource。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。