java - BeanCreationException : Injection of autowired dependencies failed -


i have 2 classes in 2 different projects, , have difficulties autowire field.

in project pack, have computation class :

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 project db, have curveaccess interface :

package com.bbb  public interface curveaccess {     // methods } 

implemented curvedao class :

package com.bbb.impl  @repository("curvedao") @transactional("cvatxmanager") public class curvedao implements curveaccess {     // methods } 

my applicationcontext.xml file pack project :

<?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> 

when running, have exception :

exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'computation': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: com.bbb.curveaccess fr.aaa.computation.curvedao; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no matching bean of type [com.bbb.curveaccess] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true), @org.springframework.beans.factory.annotation.qualifier(value=curvedao)} 

how can solve problem ?

you need class implements curveaccess interface

@component public class curveaccessimpl implements curveaccess {     //methods } 

also remove qualifier curvedao in computation bean since there no such bean id curvedao.

@autowired curveaccess curvedao; 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -