Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Unable to use @EnableMetrics in an auto configuration class #165

Open
nickcodefresh opened this issue Jan 26, 2016 · 3 comments
Open

Unable to use @EnableMetrics in an auto configuration class #165

nickcodefresh opened this issue Jan 26, 2016 · 3 comments

Comments

@nickcodefresh
Copy link

I'm trying to create a spring boot autoconfiguration library that enables metrics publication by fault in my microservices. My auto config class is defined as

@Configuration
@ConditionalOnWebApplication
@EnableMetrics
@Slf4j
public class GraphiteMetricsPublishingAutoConfiguration extends MetricsConfigurerAdapter {

but it doesn't publish metrics unless I add @EnableMetrics to the application class of the application itself. The class is called though. Any ideas why?

Thanks

Nick

@lazee
Copy link

lazee commented Jul 1, 2016

You should be able to solve it like this...

@Configuration
@ConditionalOnWebApplication
@Slf4j
public class GraphiteMetricsPublishingAutoConfiguration extends MetricsConfigurerAdapter {

    @Configuration
    @EnableMetrics
    @ComponentScan(basePackages = {"com.ryantenney"})
    public static class SpringMetricsConfiguration {
    }
}

@ryantenney
Copy link
Owner

ComponentScan in your example is not necessary.

@steklopod
Copy link

Didn't fixed :-(
Caused by: java.io.FileNotFoundException: class path resource [com/ryantenney/metrics/spring/config/annotation/MetricsConfigurerAdapter.class] cannot be opened because it does not exist

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants