-
Jun 8th, 2012, 11:15 AM
#1
[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.
-
Jun 8th, 2012, 09:08 PM
#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.
-
Jun 9th, 2012, 10:10 PM
#3
-
Jun 11th, 2012, 02:56 AM
#4

Originally Posted by
zgdnba
issue fixed.
Zgdnba,
Glad you were able to fix it - how did you solve it?
Lasse
-
Jun 13th, 2012, 07:07 AM
#5
change the "new service object" to "@autowired" at controller layer
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules