Results 1 to 7 of 7

Thread: Using @Configuration to set up SDN?

  1. #1
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default Using @Configuration to set up SDN?

    So currently I have the simple basic xml file to start up Spring Data Neo4j.

    However, most of my other beans are all defined through @Configuration classes. Is there a way to configure SDN beans simply in Java Config classes?

    I am currently using @ImportResources in my @COnfiguration class to load in the xml, but it isn't working, my repositories aren't getting created as beans.

    Thanks

    Mark

  2. #2
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Sure just have your own configuration and either extend Neo4jConfiguration or
    add the graphDatabaseService() bean in your java config.

    like this:

    Code:
    @Configuration
    public class Neo4jDatabaseConfig {
    
    	@Bean(destroyMethod = "shutdown")
    	public GraphDatabaseService graphDatabaseService() {
    		return new EmbeddedGraphDatabase("data/spring_neo4j_jpa_graph");
    	}
    
    }
    Michael

  3. #3
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    What about for replacing <neo4j:repositories> and <neo4j:config> xml tags?

    Thanks

    Mark

  4. #4
    Join Date
    Jan 2011
    Location
    Dresden, Germany
    Posts
    525

    Default

    Use @EnableNeo4jRepositories for <neo4j:repositories> and use Neo4jConfiguration.class as additional Java Config class.

  5. #5
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    Thanks Michael.

    With using

    @Bean(destroyMethod = "shutdown")
    public GraphDatabaseService graphDatabaseService() {
    return new EmbeddedGraphDatabase("data/spring_neo4j_jpa_graph");
    }

    in my Java COnfig class with the @EnableNeo4JRepositories.

    Where can we set the entitiyManagerFactory for cross stores?

    Thanks

    Mark
    Last edited by bytor99999; Jan 11th, 2013 at 12:48 PM. Reason: more stuff

  6. #6
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    OK, I think I have it all down now. I think I will go back to the documentation and update it so that we can show both options, xml and Java Config approaches to configuration.

    So,

    1) Your Java Config class should extend Neo4jConfiguration
    2) Annotate the class with @EnableNeo4jRepositories
    3) Have an @Bean method to create a bean for graphDatabaseService

    Now, the last question is how do I set EntityManagerFactory to allow for cross store. See my other thread too. Now they are converging.

    Thanks

    Mark

  7. #7
    Join Date
    Jan 2009
    Location
    Huntington Beach, CA
    Posts
    718

    Default

    OK, so I found another class CrossStoreNeo4jConfiguration. So my config now extends that.

    But I did find something that looked odd in it for the entityManager part

    @org.springframework.beans.factory.annotation.Qual ifier("&entityManagerFactory")

    What is the "&" in there for? Was that a typo?

    Thanks

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •