Announcement Announcement Module
Collapse
No announcement yet.
No qualifying bean found for dependency - Neo4J embedded & Spring Data 2.2.0 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • No qualifying bean found for dependency - Neo4J embedded & Spring Data 2.2.0

    Hello Everyone,

    I'm working on a project to measure the performance of graphdatabases for business process modelling use-cases - its part of a curricular activity on my university.

    However, I tried to alter the Galaxy-Example (Hello Worlds) to get a point to start with. To check whether everything is working on a basic level I set up a really simple test which instantiates a new World object and tries to store it via the Neo4jTemplate into the embedded GraphDb.

    This is a snippet of my dependencies (pom.xml)
    Code:
     <dependencies>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>3.2.2.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-test</artifactId>
          <version>3.2.2.RELEASE</version>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <artifactId>commons-logging</artifactId>
              <groupId>commons-logging</groupId>
            </exclusion>
          </exclusions>
        </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-neo4j</artifactId>
          <version>2.2.0.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-tx</artifactId>
          <version>3.2.2.RELEASE</version>
          <scope>compile</scope>
        </dependency>
        <dependency>
          <groupId>org.neo4j.app</groupId>
          <artifactId>neo4j-server</artifactId>
          <version>2.0.0-M02</version>
          <classifier>static-web</classifier>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    Everytime i try out my JUnit4-testcase an exception "No qualifying bean of type [start.GalaxyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency" is thrown.
    Since I'm pretty new to Spring Data and Spring in general I cannot resolve this issue on my own.

    This is a snippet of my application-context.xml
    Code:
            
        <context:spring-configured/>
    	
    	<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
        destroy-method="shutdown">
    	<constructor-arg index="0" value="target/graph.db" />
    	<constructor-arg index="1">
    		<map><entry key="enable_remote_shell" value="true"/></map>
        </constructor-arg>
    It would be very great if one of you guys could take a look over it and maybe suggest me, what my next step should be.

    This is a snippet of the GalaxyServiceTests.java
    Code:
    @ContextConfiguration( locations = {"classpath:/META-INF/application-context.xml"})
    @RunWith(SpringJUnit4ClassRunner.class)
    @Transactional
    public class GalaxyServiceTests {
    	
    @Autowired
    private GalaxyService galaxyService = new GalaxyService();
    	
    	@Autowired
    	public Neo4jTemplate template;
    
    	@Rollback(false)
    	@BeforeTransaction
    	public void cleanUpGraph() {
    		Neo4jHelper.cleanDb(template);
    	}
    	
    	@Test
    	public void allowWorldCreation(){
    		World abc = new World("Erde",1);
    		template.save(abc);
    I'm not quite sure which files are needed to gain further understanding of the problem, therefore I created a git repository on https://github.com/BenMatheja/bodega

    Thanks in advance!

    Ben

  • #2
    I managed to get it working yesterday.
    Some parts of the Application-context were pretty messed up.

    <context:spring-configured/>
    <context:annotation-config/>
    <context:component-scan base-package="components"/>
    <neo4j:config graphDatabaseService="graphDatabaseService"/>
    <neo4j:config storeDirectory="target/graph.db"/>
    <neo4j:repositories base-package="Repositories"/>
    This is a snippet of my working app-context.

    Furthermore i missed to attach an @Service to the GalaxyService class.
    Now everything is working as intended. This will maybe help someone facing the same problem.

    Comment


    • #3
      Thanks for posting the resolution! Good luck with your project.

      Comment

      Working...
      X