Announcement Announcement Module
Collapse
No announcement yet.
[Neo4j] template is null Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Neo4j] template is null

    i just learn neo4j one week, i want to transfer the example "cineasts" from maven to no-maven project in eclipse, i only hope to create an very easy simple project for my test, i add one more new neo4jContext.xml like below:


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <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"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schem...ontext-3.0.xsd
    http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schem...-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="com">
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Control ler"/>
    </context:component-scan>

    <context:spring-configured/>

    <neo4j:config storeDirectory="data/graph.db"/>
    <!--<neo4j:repositories base-package="org.neo4j.cineasts.repository"/>-->

    <tx:annotation-driven mode="proxy"/>

    </beans>


    do i need more annotation to load the template in the java code? could anybody can advise me how to do this. and i added all jars under maven into my lib.

    my requirement is:
    user request one value to controller layer,
    controller call service class,
    create one node in this service class by template .

    my service class like below:

    package com;

    import org.springframework.beans.factory.annotation.Autow ired;
    import org.springframework.data.neo4j.template.Neo4jOpera tions;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transac tional;

    import java.util.ArrayList;
    import java.util.List;

    import static java.util.Arrays.asList;

    @Service
    public class TestService {

    @Autowired Neo4jOperations template;

    @Transactional
    public void addNewNode() {
    Node n = template.createNode();
    }
    }

    why the template is null? thanks for any advise.

  • #2
    actually i only want to use template and @Transactional, for node create, index, query, i can operate those by template, and no NodeEntity class, because all entity by generate during runtime, so don't know the entity structure. so only want to use template and transactional function by spring.

    Comment


    • #3
      issue fixed.

      Comment


      • #4
        Originally posted by zgdnba View Post
        issue fixed.
        Zgdnba,

        Glad you were able to fix it - how did you solve it?

        Lasse

        Comment


        • #5
          change the "new service object" to "@autowired" at controller layer

          Comment

          Working...
          X