Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春季4&x2B;泽西岛2号&x2B;韵律学_Java_Spring_Jersey 2.0_Codahale Metrics - Fatal编程技术网

Java 春季4&x2B;泽西岛2号&x2B;韵律学

Java 春季4&x2B;泽西岛2号&x2B;韵律学,java,spring,jersey-2.0,codahale-metrics,Java,Spring,Jersey 2.0,Codahale Metrics,我正试图使用Coda Hale的度量框架对我的应用程序中的方法进行计时。我已将InstrumentedResourceMethodApplicationListener配置为将度量与Jersey 2集成,但现在我希望我的Spring注入服务和存储库也能定时。我知道有一个MetricsSpring集成,但看起来我最终会为spring和Jersey提供单独的MetricRegistry实例。是否有人能够同时为Jersey 2资源和Spring注入bean配置一个注册表?如果进行配置,您将能够使用它来

我正试图使用Coda Hale的度量框架对我的应用程序中的方法进行计时。我已将InstrumentedResourceMethodApplicationListener配置为将度量与Jersey 2集成,但现在我希望我的Spring注入服务和存储库也能定时。我知道有一个MetricsSpring集成,但看起来我最终会为spring和Jersey提供单独的MetricRegistry实例。是否有人能够同时为Jersey 2资源和Spring注入bean配置一个注册表?

如果进行配置,您将能够使用它来检测Spring bean。这应该使您能够使用构造函数参数定义
InstrumentedResourceMethodApplicationListener
,以注入Spring配置的度量存储库:

<bean id="metricsListener" class="com.codahale.metrics.jersey2.InstrumentedResourceMethodApplicationListener">
  <constructor-arg ref="metricsRegistry" />
</bean>

你也可以这样做