0

I'm implementing micrometer to spring web project. While trying to add @Timed annotation. Prior to add @Timed i'm supposed to create TimedSpect bean. But it says could not autowire no bean of MeterRegistry type found

@Configuration
public class MetricsCofiguration {
    @Bean
    public TimedAspect timedAspect(MeterRegistry registry) {
        return new TimedAspect(registry);
    }
}

1 Answers1

0

Not sure if you still need this answer but this is what i tried and its working fine.

@Configuration
@EnableAspectJAutoProxy
public class TimedConfiguration {

  @Autowired
  MeterRegistry registry;

  @Bean
  public TimedAspect timedAspect(MeterRegistry registry) {
    return new TimedAspect(registry);
  }
}

Make sure you have below starter dependency in your pom.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>
Indra Uprade
  • 773
  • 5
  • 12