Announcement Announcement Module
Collapse
No announcement yet.
Using @Configuration to set up SDN? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


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

      Thanks

      Mark

      Comment


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

        Comment


        • #5
          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, 01:48 PM. Reason: more stuff

          Comment


          • #6
            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

            Comment


            • #7
              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

              Comment

              Working...
              X