AntonIva
AntonIva

Reputation: 608

How to create Jar library file which automatically creates rest api endpoints to a spring boot application?

I want to create a library jar file. When I bring that to a spring-boot application it should make the application to have Rest API endpoints, without adding any @RestController to the spring-boot application.

For example, I want to create custom-oauth.jar library. When I include the custom-oauth.jar to the spring-boot application, the application should have http://localhost/token and http://localhost/validate ... etc.

I know this is a very common case for spring applications, and there are so many jar files which does this, but I can't find how to implement that in the Spring documentation.

Where should I start reading and what tools I should use?

Upvotes: 2

Views: 1788

Answers (1)

The most straightforward way to do this in a Boot application is to write your own autoconfiguration module. In short, you create one or more "bootstrap" @Configuration classes and list them in META-INF/spring.factories. They can then do whatever sort of operations you'd normally do (like registering @Beans or @ComponentScans for controller classes included in the jar).

Upvotes: 4

Related Questions