InfluxDBTemplate is a helper class from the community Spring Data InfluxDB project, org.springframework.data.influxdb, that wraps the old influxdb-java client so you can write points and run queries against InfluxDB 1.x with less boilerplate. It is not part of Spring Boot itself, and that project is no longer actively developed.
For new Spring Boot applications you use the official InfluxDB Java client directly, or Micrometer for metrics. This article explains what InfluxDBTemplate was for, why it is no longer the right choice, and how to do the same work today.
InfluxDB is a time-series database. Data is stored as points: a measurement name, tags (indexed strings), fields (values) and a timestamp. InfluxDBTemplate followed the Spring template pattern, like JdbcTemplate: it managed the connection to the server and exposed simple methods for writing and querying.
Typical use in the old library:
InfluxDBConnectionFactory with URL, user and password.InfluxDBTemplate bound to a database name.write(...) with Point objects and query(...) with an InfluxQL Query.The template talked to InfluxDB 1.x over its HTTP API using InfluxQL. It did not support the InfluxDB 2.x token-based API or Flux queries.
| Concern | Detail |
|---|---|
| Not part of Spring Boot | There is no spring-boot-starter for it, and Spring Data does not list InfluxDB as an official module |
| Old client | It builds on influxdb-java, which targets InfluxDB 1.x and is no longer the recommended client |
| No Boot auto-configuration | Spring Boot 2.x included InfluxDbAutoConfiguration for that client, but it was removed in Spring Boot 3.0 |
| Version mismatch | InfluxDB 2.x and 3.x use tokens, organisations and buckets, which the template does not model |
If you maintain an older application, InfluxDBTemplate still works against InfluxDB 1.x, but plan a migration.
For InfluxDB 2.x, use influxdb-client-java.
Set influxdb.client.version to the current release listed on Maven Central. Configure the client as a Spring bean:
Keep the token in an environment variable or secret store, not in source control.
getWriteApiBlocking() sends each write synchronously. For high volume use makeWriteApi(), which batches points in the background. Building a Flux string with formatted is only safe for trusted input; validate or whitelist the host value, because Flux has no parameter binding in this simple form.
If your goal is to ship Spring Boot application metrics to InfluxDB, you do not need a template at all. Add micrometer-registry-influx next to Actuator and set the export properties:
Boot then publishes JVM, HTTP and custom MeterRegistry metrics on a schedule.
InfluxDBTemplate: keep it, test it and plan a migration.influxdb-client-java as shown above.influxdb3-java client and SQL or InfluxQL queries instead of Flux.No. It belongs to the community Spring Data InfluxDB project. Spring Boot 2 had auto-configuration for the old influxdb-java client, but it was removed in Spring Boot 3.0.
No, it targets the InfluxDB 1.x API with InfluxQL. For 2.x use the official influxdb-client-java.
With the official client, create a non-blocking WriteApi using makeWriteApi() and call writePoint or writeRecord. Close the client on shutdown so pending writes flush.
No official one. You wrap the client in your own repository class, as in the example above.
InfluxDBTemplate was a template-style helper for InfluxDB 1.x from a community Spring Data project, not a Spring Boot feature, and it is now outdated. Today, use the official influxdb-client-java (or influxdb3-java) wrapped in a small repository, and use Micrometer when you only need to export metrics. Keep tokens out of source control and close the client on shutdown.