尝试在 2 类 中使用我的服务:org.springframework.beans.factory.BeanCreationException:使用名称创建 bean 时出错

Trying to use my Service in 2 classes : org.springframework.beans.factory.BeanCreationException: Error creating bean with name

尝试在 2 类 中使用我的 AccountService (@Service) 得到这个错误:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.mz.springContextWorld.repositories.AccountRepository com.mz.springContextWorld.services.AccountService.accountRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRepository': Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jTemplate'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.config.Neo4jConfiguration#0': Cannot resolve reference to bean 'graphDatabaseService' while setting bean property 'graphDatabaseService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphDatabaseService': FactoryBean threw exception on object creation; nested exception is java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /home/matthias/IdeaProjects/springContextWorld/target/neo4j-db-plain

这是我的 github 回购:https://github.com/mzober/springContextWorld/tree/CollectorManager_ErrorBranch

这里是我的 accountService 的使用:

@Autowired 
AccountService accountService;

public LoginPanel() {
 //errorline here
          this.accountService=GuiFactory.getInstance().mainWindow().getAccountService();


          init();

          addComponents();
    }

...

@Autowired
AccountService accountService;


public RegistryAndLoginListener() {

     //no error here

   accountService=GuiFactory.getInstance().mainWindow().getAccountService();

}

...从上下文配置中获取帐户服务:

<context:annotation-config/>
<context:spring-configured/>

<context:component-scan base-package="com.mz.springContextWorld.domain"/>
<context:component-scan base-package="com.mz.springContextWorld.repositories"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.listener"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.components"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.creational"/>
<context:component-scan base-package="com.mz.springContextWorld.services"/>

<neo4j:config storeDirectory="target/neo4j-db-plain"
              base-package="com.mz.springContextWorld.domain"/>
<neo4j:repositories base-package="com.mz.springContextWorld.repositories"/>

<tx:annotation-driven />

...在 MainWindow 中加载配置(我的 Spring-Data-Neo4j 演示应用程序)

@Autowired
public AccountService accountService;

public MainWindow() {
    super(PROJECTNAME);
    context= new ClassPathXmlApplicationContext("spring/spring-config.xml");
    accountService=(AccountService)context.getBean("accountService");
    ...
 }
 public AccountService getAccountService(){return this.accountService;}

账户服务:

 @Service
 @Transactional
 public class AccountService {

@Autowired
AccountRepository accountRepository;


public AccountService(){

}

@Transactional
public Iterable<Account> getAll() {
    return accountRepository.findAll();
}...

这是我的 pom.xml:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mz.springContextWorld</groupId>
<artifactId>springContextWorld</artifactId>
<packaging>jar</packaging>
<version>3.2.1.RELEASE</version>

<name>springContextWorld</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <spring.version>4.0.7.RELEASE</spring.version>
    <spring-data-neo4j.version>${project.version}</spring-data-neo4j.version>
    <slf4j.version>1.7.5</slf4j.version>
    <neo4j.version>2.1.5</neo4j.version>
    <junit.version>4.11</junit.version>
</properties>

<repositories>
    <repository>
        <id>neo4j-release-repository</id>
        <name>Neo4j Maven 2 release repository</name>
        <url>http://m2.neo4j.org/releases</url>
    </repository>
</repositories>

<dependencies>

    <!--spring data-->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-neo4j</artifactId>
        <version>${spring-data-neo4j.version}</version>
    </dependency>
    <!--spring data end-->

    <!--hibernate-->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.1.1.Final</version>
    </dependency>
    <!--hibernate end-->

    <!--test-->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-kernel</artifactId>
        <version>${neo4j.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>
    <!--test end-->

    <!--Loading Related dependencies ...logging-->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.7</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.7</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!--logging end-->

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

...我正在尝试将 txmode 设置为代理,但错误仍然存​​在...

感谢您的帮助

您的 neo4j 数据库似乎无法启动。检查最后一行日志:Error starting org.neo4j.kernel.EmbeddedGraphDatabase, /home/matthias/IdeaProjects/springContextWorld/target/neo4j-db-plain