2016-11-08 91 views
1

我正在使用Spring Boot配置neo4j數據庫。我能夠設置Spring Boot並且工作正常。但是當我配置neo4j它拋出異常org.apache.http.client.HttpResponseException: No authentication header suppliedorg.apache.http.client.HttpResponseException:沒有提供身份驗證標頭

登錄藏匿低於:

2016-11-08 15:20:54.962 INFO 4932 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet  : FrameworkServlet 'dispatcherServlet': initialization completed in 23 ms 
2016-11-08 15:24:29.062 INFO 4932 --- [nio-8080-exec-2] o.n.o.drivers.http.request.HttpRequest : Thread: 27, url: http://localhost:7474/db/data/transaction/commit, request: {"statements":[{"statement":"MATCH (user:User) WHERE user.id = {id} RETURN user","parameters":{"id":"10"},"resultDataContents":["graph"],"includeStats":false}]} 
2016-11-08 15:24:29.285 WARN 4932 --- [nio-8080-exec-2] o.n.o.drivers.http.request.HttpRequest : Thread: 27, response: No authentication header supplied. 
2016-11-08 15:24:29.288 INFO 4932 --- [nio-8080-exec-2] o.s.d.neo4j.config.Neo4jConfiguration : Intercepted exception 
2016-11-08 15:24:29.299 ERROR 4932 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.neo4j.ogm.drivers.http.request.HttpRequestException: http://localhost:7474/db/data/transaction/commit: No authentication header supplied.] with root cause 

org.apache.http.client.HttpResponseException: No authentication header supplied. 
    at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:203) ~[neo4j-ogm-http-driver-2.0.5.jar:na] 
    at org.neo4j.ogm.drivers.http.request.HttpRequest.executeRequest(HttpRequest.java:168) ~[neo4j-ogm-http-driver-2.0.5.jar:na] 
    at org.neo4j.ogm.drivers.http.request.HttpRequest.execute(HttpRequest.java:87) ~[neo4j-ogm-http-driver-2.0.5.jar:na] 
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.executeAndMap(ExecuteQueriesDelegate.java:114) ~[neo4j-ogm-core-2.0.5.jar:na] 
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:87) ~[neo4j-ogm-core-2.0.5.jar:na] 
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.queryForObject(ExecuteQueriesDelegate.java:61) ~[neo4j-ogm-core-2.0.5.jar:na] 
    at org.neo4j.ogm.session.Neo4jSession.queryForObject(Neo4jSession.java:363) ~[neo4j-ogm-core-2.0.5.jar:na] 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_31] 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_31] 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_31] 
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_31] 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] 
    at com.sun.proxy.$Proxy60.queryForObject(Unknown Source) ~[na:na] 

配置類:

public class ApplicationConfiguration extends Neo4jConfiguration{ 

    @Bean 
    public Configuration getConfiguration(){ 
     Configuration config = new Configuration(); 
     config.driverConfiguration() 
      .setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver") 
      .setURI("http://neo4j:welcome*[email protected]:7474"); 
     return config; 
    } 

    @Bean 
    public SessionFactory getSessionFactory(){ 
     return new SessionFactory(getConfiguration(), "com.ent.entity"); 
    } 

    @Bean 
    @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) 
    public Session getSession() throws Exception{ 
     return super.getSession(); 
    } 
} 
+0

怎麼沒喲你配置了ogm?你是否按照這裏的文檔:http://neo4j.com/docs/ogm-manual/current/tutorial/#tutorial-configuration –

+0

請編輯該問題並添加此信息,這裏不是真的可讀。 –

+0

您是否嘗試使用'config.driverConfiguration()。setCredentials(「neo4j」,「welcome * 123」)'而不是將憑證放入URI? –

回答

0

彈簧引導具有配置屬性,其可以在 「application.properties」 文件中設置的列表。

設置這些可能會解決這個問題:

spring.data.neo4j.username=neo4j (default user)  
spring.data.neo4j.password=neo4j (default password) 
0

這需要在頭的認證,也可以禁用驗證嘗試編輯neo4j.conf安裝目錄斌/ neo4j.conf 並取消這條線

# Whether requests to Neo4j are authenticated. 
# To disable authentication, uncomment this line 
dbms.security.auth_enabled=false  

或啓用新的DBMS連接器

# HTTP Connector. There must be exactly one HTTP connector. 
dbms.connector.http.enabled=true 
#dbms.connector.http.listen_address=:7474 
相關問題