BeanCreationException : Injektion von autowired Abhängigkeiten ist fehlgeschlagen

Ich habe 2 Klassen in 2 verschiedenen Projekte, und ich habe einige Schwierigkeiten zu autowire ein Feld.

In Projekt-pack, ich habe diese Berechnung Klasse :

package fr.aaa;

@Component
public class Computation {
    @Autowired
    @Qualifier("curveDAO")
    CurveAccess curveDAO;

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
    }
}

In der Projekt-db habe ich dies CurveAccess Schnittstelle :

package com.bbb

public interface CurveAccess {
    //some methods
}

umgesetzt durch eine CurveDAO Klasse :

package com.bbb.impl

@Repository("curveDAO")
@Transactional("cvaTxManager")
public class CurveDAO implements CurveAccess {
    //some methods
}

Meine applicationContext.xml Datei von pack-Projekt :

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd      
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">  

<import resource="classpath:spring/persistence.xml"/>

<context:annotation-config />
<context:component-scan base-package="fr.aaa.*, com.bbb.*"/> 

<util:properties id="jdbcProps" location="jdbc.properties" />   

<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
         <value>classpath:configuration.properties</value>
         <value>classpath:jdbc.properties</value>
        </list>
    </property>
</bean>

Beim laufen, ich habe diese Ausnahme :

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Computation': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.bbb.CurveAccess fr.aaa.Computation.curveDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.bbb.CurveAccess] 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), @org.springframework.beans.factory.annotation.Qualifier(value=curveDAO)}

Wie kann ich dieses problem lösen ?

  • Wo ist Ihre Umsetzung CurveAccess ?
  • Warum sind Sie das mischen von Annotationen und xml? Was für ein Alptraum.
  • Versuchen Sie nicht, verwenden Sie Platzhalter und legen Sie com.bbb und com.bbb.impl innen Basis-Paket separat.
InformationsquelleAutor l0r3nz4cc10 | 2014-01-31
Schreibe einen Kommentar