From 5edf7eb23af1cf7fff377553bbe3c1aab5f4bf23 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Mon, 20 Apr 2026 16:02:48 +0200 Subject: [PATCH] fix(alerting): @Autowired on AlertingMetrics production constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task 29's refactor added a package-private test-friendly constructor alongside the public production one. Without @Autowired Spring cannot pick which constructor to use for the @Component, and falls back to searching for a no-arg default — crashing startup with 'No default constructor found'. Detected when launching the server via the new docker-compose stack; unit tests still pass because they invoke the package-private test constructor directly. --- .../cameleer/server/app/alerting/metrics/AlertingMetrics.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cameleer-server-app/src/main/java/com/cameleer/server/app/alerting/metrics/AlertingMetrics.java b/cameleer-server-app/src/main/java/com/cameleer/server/app/alerting/metrics/AlertingMetrics.java index 3da431bb..1b3f3f48 100644 --- a/cameleer-server-app/src/main/java/com/cameleer/server/app/alerting/metrics/AlertingMetrics.java +++ b/cameleer-server-app/src/main/java/com/cameleer/server/app/alerting/metrics/AlertingMetrics.java @@ -9,6 +9,7 @@ import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Timer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; @@ -74,6 +75,7 @@ public class AlertingMetrics { * Production constructor: wraps the Postgres-backed gauge suppliers in a * 30-second TTL cache so Prometheus scrapes don't cause per-scrape DB queries. */ + @Autowired public AlertingMetrics(MeterRegistry registry, JdbcTemplate jdbc) { this(registry, () -> countRules(jdbc, true),