java - How to wire Spring service by interface in parent module? -


i'd create parent/framework module , define service makes use of interface methods.

the interface implementation should provided implementation project. somehow injection not work. why?

framework module:

package de.test;      @service     public class baseserviceexecutor {          @autowired         private icustomservice service;          public void run() {             service.use();         }     }      interface icustomservice {         void use();     }  @configuration public class frameworkappconfig {  } 

implementation module:

package de.test.impl;  @service public class mycustomservice implements icustomservice {     @override     void use() {         //custom impl     } } 

appcontext.xml: (within implementation project)

<context:component-scan base-package="de.test" />  @configuration @import(frameworkappconfig.class) @componentscan("de.test") public class implappconfig 

result:

caused by: org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type [icustomservice] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)} 

try adding context:annotation-config appcontext.xml.

see annotation-config vs component-scan


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -