views:

46

answers:

2

I am using another application's service,since everything is already made and done.

My application is to use the interface class inside the application jar. but something seem to be wrong when this code is called.

BeanFactory factory = new ClassPathXmlApplicationContext( "/Context-Controller.xml");

even if my Context-Controller.xml has this code

<context:component-scan base-package="com.package" />

My error.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.package.ServiceIamUsing] is defined: Unsatisfied dependency of type [interface com.package.ServiceIamUsing]: expected at least 1 matching bean

this is how i autowired it on my applciation.

    public class MyAppDao implements IMyAppDao {

 @Autowired
 @Qualifier("serviceIamUsing")
 private ServiceIamUsing serviceIamUsing;
    //More codes here

        }
A: 

jay, try the following: - eliminate the forward-slash "/" - in your application context xml file, try to import the application context from your external jar file if it has any --> import resource="classpath*:/META-INF/spring/*.xml"

let me know if it does/doesn't work.

jenue
jenue, it has still the same errors. it may seem that all the java files inside the jar file with autowiring in it wants a bean declaration on my context.xml.
jaded
A: 

Is there, in fact, an instance of ServiceIamUsing in the jar that is also Spring-annotated (@Component, @Service, etc.)? It's possible this is the case, but I'd like to clarify.

If not, does the jar expose a Spring context file you can import, thus adding the additional beans to your context for autowiring?

RonU