Skip to content

Commit 50e1142

Browse files
shengbinxuxushengbinbednar
authored
docs: Add instructions for using Spring Boot prior to version 2.7 (#674)
* Add instructions for using Spring Boot prior to version 2.7 * docs: Update README.md --------- Co-authored-by: xushengbin <[email protected]> Co-authored-by: Jakub Bednář <[email protected]>
1 parent 9b41ea5 commit 50e1142

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

spring/README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,27 @@ influx:
4343
connectTimeout: 5s # Connection timeout for OkHttpClient. (Default: 10s)
4444
```
4545
46+
:warning: If you are using a version of Spring Boot prior to 2.7, auto-configuration will not take effect.
47+
You need to add the `@ComponentScan` annotation to your Spring Boot startup class and include com.influxdb.spring.influx in the basePackages.
48+
For example:
49+
```java
50+
@SpringBootApplication
51+
@ComponentScan(basePackages = {"xyz", "com.influxdb.spring.influx"})
52+
public class Application {
53+
public static void main(String[] args) {
54+
ApplicationContext applicationContext = SpringApplication.run(Application.class, args);
55+
}
56+
}
57+
```
58+
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
59+
60+
4661
If you want to configure the `InfluxDBClientReactive` client, you need to include `influxdb-client-reactive` on your classpath instead of `influxdb-client-java`.
4762

4863
## Actuator for InfluxDB2 micrometer registry
4964

50-
To enable export metrics to **InfluxDB 2.x** you need to include `micrometer-registry-influx` on your classpath.
65+
To enable export metrics to **InfluxDB 2.x** you need to include `micrometer-core` on your classpath.
66+
(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.)
5167

5268
The default configuration can be override via properties:
5369

@@ -65,23 +81,24 @@ management.metrics.export.influx:
6581
num-threads: 2 # Number of threads to use with the metrics publishing scheduler. (Default: 2)
6682
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)
6783
```
84+
6885
Maven dependency:
6986

7087
```xml
7188
<dependency>
7289
<groupId>io.micrometer</groupId>
73-
<artifactId>micrometer-registry-influx</artifactId>
74-
<version>1.7.0</version>
90+
<artifactId>micrometer-core</artifactId>
91+
<version>1.11.2</version>
7592
</dependency>
7693
```
7794

7895
or when using with Gradle:
7996
```groovy
8097
dependencies {
81-
implementation "io.micrometer:micrometer-registry-influx:1.7.0"
98+
implementation "io.micrometer:micrometer-core:1.11.2"
8299
}
83-
```
84-
100+
```
101+
85102
## Actuator for InfluxDB2 health
86103

87104
The `/health` endpoint can monitor an **InfluxDB 2.x** server.

0 commit comments

Comments
 (0)