[英]“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.