Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Data x Neo4J embedded configuration
    primarykey
    data
    text
    <p>my application just tests if the environment is basically working. therefore i set up a testclass corresponding to the "Hello Worlds" example which can be found in the gitHub repository of SpringSource. Neo4j is included as static web app and runs embedded. The Webinterface is not nescessarily needed. The Problem is, when i'm starting to run the testcases via Junit i get an error like this: </p> <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'GalaxyServiceTests': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private GalaxyService GalaxyServiceTests.galaxyService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [GalaxyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} </code></pre> <p>my application config is like this</p> <pre><code> &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd"&gt; &lt;context:annotation-config/&gt; &lt;bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase" destroy-method="shutdown"&gt; &lt;constructor-arg index="0" value="target/graph.db" /&gt; &lt;constructor-arg index="1"&gt; &lt;map&gt;&lt;entry key="enable_remote_shell" value="true"/&gt;&lt;/map&gt; &lt;/constructor-arg&gt; &lt;/bean&gt; &lt;!-- &lt;bean id="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper" --&gt; &lt;!-- init-method="start" destroy-method="stop"&gt; --&gt; &lt;!-- &lt;constructor-arg ref="graphDatabaseService"/&gt; --&gt; &lt;!-- &lt;/bean&gt; --&gt; &lt;/beans&gt; </code></pre> <p>The testclass is quity simple</p> <pre><code>@ContextConfiguration( "file:c:/Users/ben/Dropbox/Semester 6/VM Graphentheorie/devEnv/bodega/application-context.xml") @RunWith(SpringJUnit4ClassRunner.class) @Transactional public class GalaxyServiceTests { // @Autowired // private GalaxyService galaxyService; @Autowired private Neo4jTemplate template; @Rollback(false) @BeforeTransaction public void cleanUpGraph() { Neo4jHelper.cleanDb(template); } @Test public void allowWorldCreation(){ // GraphDatabaseService graphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabase( "target/graph.db" ); // Node abc = graphDatabaseService.createNode(); // abc.setProperty("name","ben"); World abc = new World("Erde",1); template.save(abc); </code></pre> <p>and my pom looks like this:</p> <pre><code>&lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-context&lt;/artifactId&gt; &lt;version&gt;3.0.4.RELEASE&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-test&lt;/artifactId&gt; &lt;version&gt;3.0.7.RELEASE&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;exclusions&gt; &lt;exclusion&gt; &lt;groupId&gt;commons-logging&lt;/groupId&gt; &lt;artifactId&gt;commons-logging&lt;/artifactId&gt; &lt;/exclusion&gt; &lt;/exclusions&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;junit&lt;/groupId&gt; &lt;artifactId&gt;junit&lt;/artifactId&gt; &lt;version&gt;4.8.1&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework.data&lt;/groupId&gt; &lt;artifactId&gt;spring-data-neo4j&lt;/artifactId&gt; &lt;version&gt;2.2.0.BUILD-SNAPSHOT&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.springframework&lt;/groupId&gt; &lt;artifactId&gt;spring-tx&lt;/artifactId&gt; &lt;version&gt;3.2.2.RELEASE&lt;/version&gt; &lt;/dependency&gt; &lt;dependency&gt; &lt;groupId&gt;org.neo4j.app&lt;/groupId&gt; &lt;artifactId&gt;neo4j-server&lt;/artifactId&gt; &lt;version&gt;2.0.0-M02&lt;/version&gt; &lt;classifier&gt;static-web&lt;/classifier&gt; &lt;/dependency&gt; </code></pre> <p> Since im new to spring in connection with neo4j i cant resolve this error. if someone got a hint or some advice - thanks in advance</p> <p><strong>EDIT</strong> i changed the dependency of spring-data from 2.2.0.BUILD-SNAPSHOT to 2.2.0.RELEASE.. now neo4j is running till the point when an error is passed to console: </p> <pre><code>21:11:48.196 [main] ERROR o.s.test.context.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@7e26f5a7] to prepare test instance [GalaxyServiceTests@64d74895] java.lang.IllegalStateException: Failed to load ApplicationContext </code></pre> <p><strong>EDIT2</strong> I've published the repository on <a href="http://github.com/BenMatheja/bodega" rel="nofollow">http://github.com/BenMatheja/bodega</a></p> <p><strong>EDIT3</strong> Something with the path of application-context.xml was messed up. I fixed that issue with <code>@ContextConfiguration( locations = {"classpath:/META-INF/application-context.xml"})</code></p> <p>I'm at the point that an Exception </p> <blockquote> <p>No qualifying bean of type [start.GalaxyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency</p> </blockquote> <p>is thrown each time i run the JUnit4 test now.</p> <p><strong>EDIT4</strong> I managed to get it working yesterday. Some parts of the Application-context were pretty messed up.</p> <pre><code>&lt;context:spring-configured/&gt; &lt;context:annotation-config/&gt; &lt;context:component-scan base-package="components"/&gt; &lt;neo4j:config graphDatabaseService="graphDatabaseService"/&gt; &lt;neo4j:config storeDirectory="target/graph.db"/&gt; &lt;neo4j:repositories base-package="Repositories"/&gt; </code></pre> <p>This is a snippet of my working app-context. Furthermore i missed to attach an @Service to the GalaxyService class.</p> <p>Now everything is working as intended. This will maybe help someone facing the same problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload