gpt4 book ai didi

java - "not authorized to execute this request"使用 arangodb java 驱动程序

转载 作者:行者123 更新时间:2023-11-30 06:38:39 25 4
gpt4 key购买 nike

我想在 Eclipse 上的 Maven 项目中使用 ArangoDB 的 java 驱动程序。我正在尝试遵循可用的 ArangoDB java 驱动程序教程 here ,但我什至无法让更简单的应用程序运行,即使从一个干净的项目开始也是如此。

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)

最佳答案

您需要指定到数据库的连接数据,如用户、密码等,所有数据库都需要成功连接,再次检查类的javadoc Builder并设置用户和密码。

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

在这里,您无需进行任何设置并构建 ArrangoDb 实例,而无需任何连接数据

关于java - "not authorized to execute this request"使用 arangodb java 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44775333/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com