2017-10-04 225 views
0

我尝试连接到influxDb在我的Java代码:
InfluxDB influxDB = InfluxDBFactory.connect("http://serverIp:8086", "admin", "admin"); 我得到错误:
异常在连接到influxDb

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 

我使用Maven和依赖于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> 

什么okhttp3依赖需要添加?或者如何解决这个问题?

回答

1

您错过了com.squareup.okhttp3依赖项。实际上,根据Maven Repository,InfluxDB依赖本身具有一组编译依赖关系。

请参阅here了解这些的完整列表。

相关问题