From f09c49e4d39fd5812903c69ba61d1014b81e38ea Mon Sep 17 00:00:00 2001 From: xushengbin Date: Sun, 28 Jan 2024 10:58:02 +0800 Subject: [PATCH 1/2] Add instructions for using Spring Boot prior to version 2.7 --- spring/README.md | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/spring/README.md b/spring/README.md index 67ab490814..d22464615f 100644 --- a/spring/README.md +++ b/spring/README.md @@ -43,11 +43,27 @@ influx: connectTimeout: 5s # Connection timeout for OkHttpClient. (Default: 10s) ``` +:warning: If you are using a version of Spring Boot prior to 2.7, auto-configuration will not take effect. +You need to add the @ComponentScan annotation to your Spring Boot startup class and include com.influxdb.spring.influx in the basePackages. +For example: +```java +@SpringBootApplication +@ComponentScan(basePackages = {"xxx", "com.influxdb.spring.influx"}) +public class Application { + public static void main(String[] args) { + ApplicationContext applicationContext = SpringApplication.run(Application.class, args); + } +} +``` +The reason for this is that Spring Boot 2.7 has changed the way that auto-configuration and management context classes are discovered. see https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.7-Release-Notes + + If you want to configure the `InfluxDBClientReactive` client, you need to include `influxdb-client-reactive` on your classpath instead of `influxdb-client-java`. ## Actuator for InfluxDB2 micrometer registry -To enable export metrics to **InfluxDB 2.x** you need to include `micrometer-registry-influx` on your classpath. +To enable export metrics to **InfluxDB 2.x** you need to include `micrometer-core` on your classpath. +(Due to package conflicts, the `spring-boot-actuator` may have relied on an earlier version of the `micrometer-core`. Therefore, it is necessary to specify a higher version here.) The default configuration can be override via properties: @@ -65,23 +81,24 @@ management.metrics.export.influx: num-threads: 2 # Number of threads to use with the metrics publishing scheduler. (Default: 2) batch-size: 10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. (Default: 10000) ``` + Maven dependency: ```xml io.micrometer - micrometer-registry-influx - 1.7.0 + micrometer-core + 1.11.2 ``` or when using with Gradle: ```groovy dependencies { - implementation "io.micrometer:micrometer-registry-influx:1.7.0" + implementation "io.micrometer:micrometer-core:1.11.2" } -``` - +``` + ## Actuator for InfluxDB2 health The `/health` endpoint can monitor an **InfluxDB 2.x** server. From d86e248a928c0313d52ae6b7f8e191932a2bc71c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Bedn=C3=A1=C5=99?= Date: Mon, 29 Jan 2024 08:46:51 +0100 Subject: [PATCH 2/2] docs: Update README.md --- spring/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring/README.md b/spring/README.md index d22464615f..ea45d0e5a7 100644 --- a/spring/README.md +++ b/spring/README.md @@ -44,11 +44,11 @@ influx: ``` :warning: If you are using a version of Spring Boot prior to 2.7, auto-configuration will not take effect. -You need to add the @ComponentScan annotation to your Spring Boot startup class and include com.influxdb.spring.influx in the basePackages. +You need to add the `@ComponentScan` annotation to your Spring Boot startup class and include com.influxdb.spring.influx in the basePackages. For example: ```java @SpringBootApplication -@ComponentScan(basePackages = {"xxx", "com.influxdb.spring.influx"}) +@ComponentScan(basePackages = {"xyz", "com.influxdb.spring.influx"}) public class Application { public static void main(String[] args) { ApplicationContext applicationContext = SpringApplication.run(Application.class, args);