我正在使用mint 17.2並且擁有neo4j 3.06 Comunity Edition,它在localhost:7474上正常運行。我怎樣才能讓java和neo4j在eclipse中工作
我希望在使用Eclipse Mars 2的Java 1.08中進行編程,但是我無法使其工作。
我使用的是Maven項目,並已在我的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>com.geekcap.informit</groupId>
<artifactId>neo4j-sample-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>neo4j-sample-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
</project>
我已經在我的app.java文件下列
package com.geekcap.informit.neo4j_sample_app;
import org.neo4j.driver.v1.*;
public class App
{
public static void main(String[] args)
{
Driver driver = GraphDatabase.driver("bolt://localhost:7474", AuthTokens.basic("neo4j", "neo4j"));
Session session = driver.session();
session.run("CREATE (a:Person {name:'Arthur', title:'King'})");
StatementResult result =
session.run("Match (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title");
while (result.hasNext()) {
Record record = result.next();
System.out.println(record.get("title").asString() + " " +
record.get("name").asString());
}
session.close();
driver.close();
}
我收到以下錯誤,當我嘗試運行它作爲一個Java應用程序。
Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Unable to process request: Unrecognized SSL message, plaintext connection?
at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:87)
at org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:63)
at org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)
at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:191)
at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:180)
at org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212)
at org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164)
at org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118)
at org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109)
at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)
at com.geekcap.informit.neo4j_sample_app.App.main(App.java:12)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:156)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:868)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.unwrap(TLSSocketChannel.java:186)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.runHandshake(TLSSocketChannel.java:127)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:95)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:77)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:70)
at org.neo4j.driver.internal.connector.socket.SocketClient$ChannelFactory.create(SocketClient.java:235)
at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:74)
... 10 more
謝謝您的回覆弗蘭克。我嘗試了以上,它仍然無法正常工作。我使用端口7474,因爲我可以通過該端口訪問瀏覽器。 – Laurence
我敢打賭,協議是不活躍的,錯誤消息和堆棧跟蹤略有不同。我已經更新了答案。 –
嘗試從dbms.connector.bolt.address = 0.0.0.0:7687中刪除#但它仍然失敗,但故障也已更改:無法處理請求:常規SSLEngine問題 – Laurence