Spring-Data-Neo4J:如何登录远程服务器?
Spring-Data-Neo4J: How do log into the remote server?
我正在使用 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();
}
}
};
}
}
旁注
4.0.0 里程碑 1 非常棒。如果有人在使用 3.x.x,我建议您检查一下!
当前通过系统属性传递用户名和密码
例如
-Drun.jvmArguments="-Dusername=<usr> -Dpassword=<pwd>"
或
System.setProperty("username", "neo4j");
System.setProperty("password", "password");
https://jira.spring.io/browse/DATAGRAPH-627 已开放(虽然不是针对 4.0 RC1),请随意添加 comments/vote
我正在使用 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();
}
}
};
}
}
旁注
4.0.0 里程碑 1 非常棒。如果有人在使用 3.x.x,我建议您检查一下!
当前通过系统属性传递用户名和密码
例如
-Drun.jvmArguments="-Dusername=<usr> -Dpassword=<pwd>"
或
System.setProperty("username", "neo4j");
System.setProperty("password", "password");
https://jira.spring.io/browse/DATAGRAPH-627 已开放(虽然不是针对 4.0 RC1),请随意添加 comments/vote