Spi*_*der 2 java neo4j spring-data-neo4j spring-data-neo4j-4
我正在使用Spring-Data-Neo4j 4.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();
}
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
边注
4.0.0里程碑1绝对是太棒了.如果有人使用3.xx,我建议检查出来!
用户名和密码当前通过系统属性传递
例如
-Drun.jvmArguments="-Dusername=<usr> -Dpassword=<pwd>"
Run Code Online (Sandbox Code Playgroud)
要么
System.setProperty("username", "neo4j");
System.setProperty("password", "password");
Run Code Online (Sandbox Code Playgroud)
https://jira.spring.io/browse/DATAGRAPH-627是开放的(虽然不是针对4.0 RC1的目标),请随时添加评论/投票
| 归档时间: |
|
| 查看次数: |
498 次 |
| 最近记录: |