[英]“not authorized to execute this request” using the arangodb java driver
我想在 Eclipse 上的 Maven 項目中使用 ArangoDB 的 java 驅動程序。 我正在嘗試按照此處提供的 ArangoDB 的 Java 驅動程序教程進行操作,但我什至無法讓更簡單的應用程序工作,即使從一個干凈的項目開始。
主.java:
package test;
import com.arangodb.ArangoDB;
public class main {
public static void main(String[] args) {
ArangoDB arangoDB = new ArangoDB.Builder().build();
arangoDB.createDatabase("myDatabase");
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>arangodb-java-driver</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
</project>
運行代碼時出現以下錯誤:
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" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
at test.main.main(main.java:12)
我嘗試了其他基本操作,但都不起作用(甚至是一個簡單的arangoDB.getVersion();
)。
如果我將以下依賴項添加到 pom.xml,它會刪除警告而不是錯誤:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.22</version>
</dependency>
結果:
Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
at test.main.main(main.java:12)
您需要指定到您的數據庫的連接數據,如用戶、密碼等,所有數據庫需要成功連接,再次檢查類Builder 的javadoc 並設置用戶和密碼。
ArangoDB arangoDB = new ArangoDB.Builder().build();
在這里,您什么都不設置,並在沒有任何連接數據的情況下構建ArrangoDb
實例
我想在Eclipse上的Maven項目中為ArangoDB使用Java驅動程序。 我正在嘗試按照此處提供的ArangoDB Java驅動程序教程進行操作,但是即使從一個干凈的項目開始,我什至無法使更簡單的應用程序正常工作。
main.java:
package test;
import com.arangodb.ArangoDB;
public class main {
public static void main(String[] args) {
ArangoDB arangoDB = new ArangoDB.Builder().build();
arangoDB.createDatabase("myDatabase");
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.arangodb</groupId>
<artifactId>arangodb-java-driver</artifactId>
<version>4.2.0</version>
</dependency>
</dependencies>
</project>
運行代碼時出現以下錯誤:
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" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
at test.main.main(main.java:12)
我嘗試了其他基本操作,沒有任何效果(即使是簡單的arangoDB.getVersion();
)。
如果將以下依賴項添加到pom.xml,它將刪除警告,但不會刪除錯誤:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.22</version>
</dependency>
結果:
Exception in thread "main" com.arangodb.ArangoDBException: Response: 401, Error: 11 - not authorized to execute this request
at com.arangodb.internal.velocystream.VstCommunication.checkError(VstCommunication.java:106)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:134)
at com.arangodb.internal.velocystream.VstCommunicationSync.execute(VstCommunicationSync.java:46)
at com.arangodb.internal.velocystream.VstCommunication.execute(VstCommunication.java:96)
at com.arangodb.internal.velocystream.VstProtocol.execute(VstProtocol.java:46)
at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:58)
at com.arangodb.ArangoDB.createDatabase(ArangoDB.java:437)
at test.main.main(main.java:12)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.