2016-08-22 4 views
2

新しいスタイル(Spring Data Neo4j 4.1.2.RELEASE)のNeo4jConfigurationを使用すると、埋め込みGraphDatabaseServiceへの参照をWeb UIに渡すことはできますか?Springブート+ Neo4jはGraphDatabaseService Beanを取得しますか?

新しいスタイルの設定:

@Configuration 
@EnableNeo4jRepositories(basePackages = "fu.bar") 
@EnableTransactionManagement 
public class Neo4j extends Neo4jConfiguration { 

    @Bean 
    @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.TARGET_CLASS) 
    public Session getSession() throws Exception { 
     return super.getSession(); 
    } 

    @Bean 
    public org.neo4j.ogm.config.Configuration getConfiguration() { 
     org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration(); 
     config.driverConfiguration() 
      .setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver") 
      .setURI("file:///var/tmp/graph.db"); 
     return config; 
    } 

    @Bean 
    public SessionFactory getSessionFactory() { 
     SessionFactory sessionFactory = new SessionFactory(getConfiguration(), "fu.bar"); 
     return sessionFactory; 
    } 

私は役立ちますが、私はブートはインスタンスどこかがあると疑われるのJavadocには何も見ていませんよ。

ありがとうございました。

String uri = Components.driver().getConfiguration().getURI() + 
         "/db/data/index/node/" + indexName; 
HttpPost httpPost = new HttpPost(uri); 

これらの例:

EmbeddedDriver embeddedDriver = (EmbeddedDriver) Components.driver(); 
GraphDatabaseService databaseService = embeddedDriver.getGraphDatabaseService(); 

HTTPで、データベースへの直接アクセスをして達成することができ、次のよう

+0

https://msummers.github.io/ここに完全な作業用コードスニペットを掲載しました。 –

答えて

2

あなたが埋め込まれたドライバを使用している場合は、GraphDatabaseServiceを得ることができますSpring Data Neo4jリファレンスガイドのsection on indexesから来ています。

関連する問題