java.lang.ClassNotFoundException: org.apache.http.impl.client.cache.CacheConfig
java.lang.ClassNotFoundException: org.apache.http.impl.client.cache.CacheConfig
我正在尝试将 CouchDB 与 JAVA 一起使用。这太糟糕了!!!
这是我在网上找到的代码:
package project.couchdb;
import java.net.MalformedURLException;
import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbConnector;
import org.ektorp.impl.StdCouchDbInstance;
import org.ektorp.support.DesignDocument;
public class CouchConnect {
public static void main(String[] args) throws MalformedURLException{
//connection
HttpClient client = new StdHttpClient.Builder().url("http://127.0.0.1:5984").build();
CouchDbInstance dbIstance = new StdCouchDbInstance(client);
//database
CouchDbConnector db = new StdCouchDbConnector("test", dbIstance);
db.createDatabaseIfNotExists();
//document
DesignDocument doc = new DesignDocument("test_doc");
db.create(doc);
}
}
错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/cache/CacheConfig
at org.ektorp.http.StdHttpClient$WithCachingBuilder.withCaching(StdHttpClient.java:533)
at org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:523)
at project.couchdb.CouchConnect.main(CouchConnect.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.client.cache.CacheConfig
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
我刚刚添加了一些 .jar,因为控制台给我类似 'ClassNotFoundException' 的错误,但这次我找不到要添加的 .jar 文件。有人 link 下载 .jar 或任何其他解决方案吗?
PS:如果相关
,我在 windows 10 上使用 eclipse
添加剩余的 .jar 后出现以下错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.client.utils.URLEncodedUtils.parsePathSegments(Ljava/lang/CharSequence;)Ljava/util/List;
at org.apache.http.impl.client.cache.CacheKeyGenerator.getRequestUri(CacheKeyGenerator.java:78)
at org.apache.http.impl.client.cache.CacheKeyGenerator.getURI(CacheKeyGenerator.java:118)
at org.apache.http.impl.client.cache.CacheInvalidator.flushInvalidatedCacheEntries(CacheInvalidator.java:86)
at org.apache.http.impl.client.cache.BasicHttpCache.flushInvalidatedCacheEntriesFor(BasicHttpCache.java:361)
at org.apache.http.impl.client.cache.CachingHttpClient.flushEntriesInvalidatedByRequest(CachingHttpClient.java:596)
at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:457)
at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:345)
at org.ektorp.http.StdHttpClient.executeRequest(StdHttpClient.java:177)
at org.ektorp.http.StdHttpClient.executeRequest(StdHttpClient.java:192)
at org.ektorp.http.StdHttpClient.head(StdHttpClient.java:146)
at org.ektorp.http.RestTemplate.head(RestTemplate.java:109)
at org.ektorp.impl.StdCouchDbInstance.checkIfDbExists(StdCouchDbInstance.java:98)
at org.ektorp.impl.StdCouchDbInstance.createDatabaseIfNotExists(StdCouchDbInstance.java:63)
at org.ektorp.impl.StdCouchDbInstance.createDatabaseIfNotExists(StdCouchDbInstance.java:59)
at org.ektorp.impl.StdCouchDbConnector.createDatabaseIfNotExists(StdCouchDbConnector.java:413)
at project.couchdb.CouchConnect.main(CouchConnect.java:23)
您的库列表中还需要 httpclient-cache。
宣布它似乎还为时过早"horrible"。
我正在尝试将 CouchDB 与 JAVA 一起使用。这太糟糕了!!! 这是我在网上找到的代码:
package project.couchdb;
import java.net.MalformedURLException;
import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbConnector;
import org.ektorp.impl.StdCouchDbInstance;
import org.ektorp.support.DesignDocument;
public class CouchConnect {
public static void main(String[] args) throws MalformedURLException{
//connection
HttpClient client = new StdHttpClient.Builder().url("http://127.0.0.1:5984").build();
CouchDbInstance dbIstance = new StdCouchDbInstance(client);
//database
CouchDbConnector db = new StdCouchDbConnector("test", dbIstance);
db.createDatabaseIfNotExists();
//document
DesignDocument doc = new DesignDocument("test_doc");
db.create(doc);
}
}
错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/impl/client/cache/CacheConfig
at org.ektorp.http.StdHttpClient$WithCachingBuilder.withCaching(StdHttpClient.java:533)
at org.ektorp.http.StdHttpClient$Builder.build(StdHttpClient.java:523)
at project.couchdb.CouchConnect.main(CouchConnect.java:18)
Caused by: java.lang.ClassNotFoundException: org.apache.http.impl.client.cache.CacheConfig
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
我刚刚添加了一些 .jar,因为控制台给我类似 'ClassNotFoundException' 的错误,但这次我找不到要添加的 .jar 文件。有人 link 下载 .jar 或任何其他解决方案吗?
PS:如果相关
,我在 windows 10 上使用 eclipse添加剩余的 .jar 后出现以下错误:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.client.utils.URLEncodedUtils.parsePathSegments(Ljava/lang/CharSequence;)Ljava/util/List;
at org.apache.http.impl.client.cache.CacheKeyGenerator.getRequestUri(CacheKeyGenerator.java:78)
at org.apache.http.impl.client.cache.CacheKeyGenerator.getURI(CacheKeyGenerator.java:118)
at org.apache.http.impl.client.cache.CacheInvalidator.flushInvalidatedCacheEntries(CacheInvalidator.java:86)
at org.apache.http.impl.client.cache.BasicHttpCache.flushInvalidatedCacheEntriesFor(BasicHttpCache.java:361)
at org.apache.http.impl.client.cache.CachingHttpClient.flushEntriesInvalidatedByRequest(CachingHttpClient.java:596)
at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:457)
at org.apache.http.impl.client.cache.CachingHttpClient.execute(CachingHttpClient.java:345)
at org.ektorp.http.StdHttpClient.executeRequest(StdHttpClient.java:177)
at org.ektorp.http.StdHttpClient.executeRequest(StdHttpClient.java:192)
at org.ektorp.http.StdHttpClient.head(StdHttpClient.java:146)
at org.ektorp.http.RestTemplate.head(RestTemplate.java:109)
at org.ektorp.impl.StdCouchDbInstance.checkIfDbExists(StdCouchDbInstance.java:98)
at org.ektorp.impl.StdCouchDbInstance.createDatabaseIfNotExists(StdCouchDbInstance.java:63)
at org.ektorp.impl.StdCouchDbInstance.createDatabaseIfNotExists(StdCouchDbInstance.java:59)
at org.ektorp.impl.StdCouchDbConnector.createDatabaseIfNotExists(StdCouchDbConnector.java:413)
at project.couchdb.CouchConnect.main(CouchConnect.java:23)
您的库列表中还需要 httpclient-cache。
宣布它似乎还为时过早"horrible"。