IsaacLevon
IsaacLevon

Reputation: 2580

How to add a Spring Boot support to an external library?

I have a library I'm developing, and let's say it offers some service FooService.

Now, in order to instantiate it you need to pass some arguments to the constructor.

Typically (if FooService is in the same project), you are supposed to write FooServiceConfig class annotated with @Configuration and instantiate using @Valueed properties.

How can it be done when you use FooService from an external library?

What I'd like to achieve is to be able to instantiate the FooService using @Autowired (and putting the correct config in application.properties)

Upvotes: 1

Views: 436

Answers (1)

Marcos Barbero
Marcos Barbero

Reputation: 1119

If your library is supposed to work within Spring's projects you can create your own auto-configuration.

Once you have everything configured it will work in the same way as any other spring-boot-starter.

Upvotes: 4

Related Questions