I try connect to influxDb in my Java code: InfluxDB influxDB = InfluxDBFactory.connect("http://serverIp:8086", "admin", "admin");
I get error:
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/Interceptor
at org.influxdb.InfluxDBFactory.connect(InfluxDBFactory.java:47)
at InfluxDbConnector.main(InfluxDbConnector.java:15)
Caused by: java.lang.ClassNotFoundException: okhttp3.Interceptor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
I use Maven and dependency in pom:
<dependency>
<groupId>org.influxdb</groupId>
<artifactId>influxdb-java</artifactId>
<version>2.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/influxdb-java-2.7.jar</systemPath>
</dependency>
What okhttp3 dependency need add? Or how resolve this problem?
You are missing the com.squareup.okhttp3
dependency. Indeed, according to Maven Repository your InfluxDB dependency itself has a set of Compile dependencies.
Please see here for the complete list of those.