spring - External Java Library issue with Autowiring and injecting bean -
i have created spring boot application managed maven. i'm retrieving company's library our maven repository.
in library, have service interface, not being annotated '@service':
public interface myservice { //... }
this service has 1 implementation :
public class defaultmyservice implements myservice { //... }
this library context managed old spring way (in applicationcontext.xml file). read normally, spring boot able find implementation if there's 1 in scope.
when try run "spring-boot:run" on project, fail following error :
no qualifying bean of type 'com.pharmagest.saml.samlservice' available: expected @ least 1 bean qualifies autowire candidate. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}
i tried:
- to add @componentscan on configuration class, including packages in error :
@componentscan(basepackages={"com.mycompany.web", "com.mycompany.thelibrary.client.*", "com.mycompany.thelibrary.services.*"})
- to add bean definition in applicationcontext.xml (if add interface tells me can define it, heard spring can find default implementation if there 1 ?)
- to add library @ "runtime" in projects options
- to add library external resource not via maven
in cases can maven build can't run project. have advice me ? thanks!
- won't work
defaultmyservice
has no@component
(or@service
) annotation not detected. - bean definition has concrete instance use
defaultmyservice
instead of interface. spring not detect understanding wrong - and 4. not change adding dependencies without proper 1. or 2. nothing.
just add @bean
configuration
@bean public defaultmyservice myservice() { return new defaultmyservice(); }
or import other libraries applicatiponcontext.xml
should do.
@importresource("classpath:/applicationcontext.xml")
add next @springbootapplication
.
Comments
Post a Comment