java SpringDataNeo4J:如何登录到远程服务器?
我使用的是Spring-Data-neo4j4.0.0。M1,并尝试连接到服务器。我得到一个例外:
Caused by: org.apache.http.client.HttpResponseException: Unauthorized
我在服务器界面上有一个密码,但我不知道如何告诉Spring
@Configuration
@EnableNeo4jRepositories(basePackages = "com.noxgroup.nitro.persistence")
@EnableTransactionManagement
public class MyConfiguration extends Neo4jConfiguration {
@Bean
public Neo4jServer neo4jServer () {
/*** I was quite surprised not to see an overloaded parameter here ***/
return new RemoteServer("http://localhost:7474");
}
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory("org.my.software.domain");
}
@Bean
ApplicationListener<BeforeSaveEvent> beforeSaveEventApplicationListener() {
return new ApplicationListener<BeforeSaveEvent>() {
@Override
public void onApplicationEvent(BeforeSaveEvent event) {
if (event.getEntity() instanceof User) {
User user = (User) event.getEntity();
user.encodePassword();
}
}
};
}
}
旁注
4.0.0里程碑1绝对是太棒了。如果有人使用3。x、 x,我建议你去看看
# 1 楼答案
用户名和密码当前通过系统属性传递
例如
或者
https://jira.spring.io/browse/DATAGRAPH-627是开放的(但不是针对4.0 RC1),请随时添加评论/投票