繁体   English   中英

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.xx,建议您将其检出!

用户名和密码当前通过系统属性传递

例如

-Drun.jvmArguments="-Dusername=<usr> -Dpassword=<pwd>"

要么

 System.setProperty("username", "neo4j");
 System.setProperty("password", "password");

https://jira.spring.io/browse/DATAGRAPH-627已打开(尽管不针对4.0 RC1),请随时添加评论/投票

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM