i have a controller for my http url with autowired event for my database (everything work fine)
@RestController public class CalculateDistance {
@Autowired MyDatabase mydb
some code
@GetMapping(value = "/url")
public Strng get() {
return mydb.fetch("my query");
}
now i have the same autowired but its not working, i get null instead of my object
@Component public class PrometheusMonitor {
@Autowired MyDatabase mydb
public PrometheusMonitor(MeterRegistry registry) {
meterRegistry = registry;
mydb = null ...
i get an exception becuase mydb = null
but it works for my http controller