2017-08-22 16 views
0

我是neo4j的新手,春天是彈簧和組合。當我開始調試,我得到以下異常:線程 「main」 org.springframework.beans.factory.NoSuchBeanDefinitionException帶Spring的Neo4j:沒有名爲'getSessionFactory'的bean available

例外:無 豆名爲 '了getSessionFactory' 可用

任何人都可以請幫幫我?

apllication-context.xml中:

<?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/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 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx.xsd"> 

    <context:component-scan base-package="de.unileipzig.analyzewikipedia.neo4j" /> 

    <!--neo4j:config storeDirectory="C:/temp/neo4jdatabase" base-package="de.unileipzig.analyzewikipedia.neo4j.dataobjects"/--> 

    <neo4j:repositories base-package="de.unileipzig.analyzewikipedia.neo4j.repositories"/> 

    <tx:annotation-driven /> 

    <bean id="graphDatabaseService" class="org.springframework.data.neo4j.support.GraphDatabaseServiceFactoryBean" 
      destroy-method="shutdown" scope="singleton"> 
     <constructor-arg value="C:/develop/uni/analyze-wikipedia-netbeans/database"/> 
     <constructor-arg> 
      <map> 
       <entry key="allow_store_upgrade" value="true"/> 
      </map> 
     </constructor-arg> 
    </bean> 
</beans> 

啓動級

包de.unileipzig.analyzewikipedia.neo4j.console;

import de.unileipzig.analyzewikipedia.neo4j.dataobjects.Article; 
import de.unileipzig.analyzewikipedia.neo4j.service.ArticleService; 
import java.io.File; 
import org.springframework.context.ApplicationContext; 
import org.springframework.context.support.ClassPathXmlApplicationContext; 

public class Neo4JConsole { 
    /** 
    * MAIN: start the java file 
    * 
    * @param args as string array 
    */ 
    public static void main(String[] args) { 

     String cwd = (new File(".")).getAbsolutePath(); 
     ApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml"); 
     ArticleService service = (ArticleService) context.getBean("articleService"); 

     Article art = createArticle(); 
     createArticle(service, art); 

     System.out.println("Article created"); 
    }  

    private static Article createArticle() { 
     Article article = new Article(); 
     article.setTitle("Title"); 
     return article; 
    } 

    private static Article createArticle(ArticleService service, Article art) { 
     return service.create(art); 
    } 
} 

謝謝。

+0

您可以發佈完整的異常日誌? –

回答

0

你有這個配置嗎?

@Configuration 
@EnableNeo4jRepositories("org.neo4j.cineasts.repository") 
@EnableTransactionManagement 
@ComponentScan("org.neo4j.cineasts") 
public class PersistenceContext extends Neo4jConfiguration { 

    @Override 
    public SessionFactory getSessionFactory() { 
     return new SessionFactory("org.neo4j.cineasts.domain"); 
    } 
} 

欲瞭解更多信息,嘗試一下here

+0

謝謝。閱讀時忽略了這部分。 –

相關問題