user1986244
user1986244

Reputation: 267

unable to autowire custom spring boot library project to my application

Importing custom spring-boot library jar to my application, and autowiring show the following error when I run the application

Parameter 0 of constructor in com.dilla.de.orca.addresssvc.service.TestScheduler required a bean of type 'com.dilla.de.orca.flowersvc.service.FlowerServiceImpl' that could not be found.

The Library module has following packages

FlowerSvcLibApplication.java
    public static void main(final String[] args) {
        SpringApplication.run(FlowerSvcLibApplication.class, args);
    }

I was autowiring the Flower Service interface as follows, in my application to test functionality of library jar

@Component
public class MyFlowerService {

    private  FlowerService service;
    @Autowired
    public MyFlowerService(final FlowerService service) {
        this.service = service;
    }

I got the error I posted earlier. I did do more research, and one suggestion was creating “own auto-configuration”, but I still did not understand. How do I create autoConfiguration class to handle to autowire my library class, and also how does client using my library provide application property values. Currently, I hard coded actual values for example a webservice url, and now client can change this to be test or prod, and to do that how does my library module setup should be?

Upvotes: 1

Views: 308

Answers (1)

Apurv Sheth
Apurv Sheth

Reputation: 1

Please check @ComponenetScan & make sure that it has package path something like this “com.dilla.de.orca”

Upvotes: 0

Related Questions