How to Create a Java Library: From Scratch to Maven Central
If you usually need to rewrite or copy similar code between different projects, it may be time to stop replicating it and create a library.
To use your library in different projects, you have to publish it on a repository like Maven Central Repository.