-->

“无权执行此请求”使用arangodb Java驱动程序(“not authorized to ex

2019-09-27 04:56发布

我想使用ArangoDB的Java驱动程序在Eclipse的Maven项目。 我试图遵循为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)

Answer 1:

您需要指定连接数据到你的数据库,如用户,密码和等,都什么是数据库需要成功地连接,再次检查类的javadoc 生成器并设置用户名和密码。

ArangoDB arangoDB = new ArangoDB.Builder().build();

在这里,你什么都不设置和建立ArrangoDb没有任何连接数据实例在所有



文章来源: “not authorized to execute this request” using the arangodb java driver