Skip to content

abeshenov/serviceloader-example

Repository files navigation

Demo of java.util.ServiceLoader

This is a small demo of how ServiceLoaders work in Java. For more information, see my note https://abeshenov.github.io/blog/2023-01-08-serviceloader.html

Running the demo

First, package our service provider into a JAR:

./gradlew hello-world-service:jar

Now confirm that it really provides our service:

jar --file hello-world-service/build/libs/hello-world-service.jar --describe-module

Copy the JAR to the application directory:

cp hello-world-service/build/libs/hello-world-service.jar app

Run the app:

./gradlew app:run