简体   繁体   English

从 Micronaut 中的 application.yml 访问属性

[英]Access Property from application.yml in Micronaut

I am trying to access a property from my application.yml file in my Gatling Simulation class.我正在尝试从我的 Gatling Simulation class 中的 application.yml 文件访问属性。 I am using Micronaut Framework.我正在使用 Micronaut 框架。

My application.yml is as follows:我的 application.yml 如下:

gatling:
  url: 'http://google.com'

My attempts to get the value are as follows:我尝试获取值如下:

Attempt 1:尝试1:

@Value("${gatling.url}")
String url;

Attempt 2:尝试2:

@Property(name = "gatling.url");
String url;

But both these attempts return NPE.但是这两种尝试都返回了 NPE。

There's no way this can work.这是不可能的。 Gatling Simulations are instantiated by its own engine, not by Micronaut and its dependency injection module. Gatling Simulations 由它自己的引擎实例化,而不是由 Micronaut 及其依赖注入模块实例化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM