spring boot scanning and injecting external non-spring beans

What does it take, or is it even possible for Spring to scan and inject non-spring annotated classes? For example.

resource.jar

com.project.resource.ResourceInterface

com.project.resource.StandardResource <-- concrete implementation

@Singleton <--- Standard CDI annotation

public class StandardResource implements ResourceInterface{

@Override

public void something(){}

}

Now let's say I have a spring boot application which depends on resource.jar.

com.project.resource.SpringApp

@SpringBootApplication(scanBasePackages = {"com.project"})

@EnableAutoConfiguration

public class SpringApp{

... initializer

@Inject

private ResourceInterface resourceService; <--- this is not found

}

Is this supposed to work out of the box? Is this even possible? I'm using spring boot 2.0.0.RELEASE. I'm getting the following error:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating...

Read More »

By: StackOverFlow - Friday, 13 April

Related Posts