Reputation: 1093
I have a Spring web MVC framework project. I am going to add a service to my project to send emails using Apache Commons Email (service has external dependencies). I am thinking to use this Email service in my other projects as well and I do not want to copy the classes between projects. The solution could be: Email service can be an independent project with some interfaces to accept the Email information (msg, To, From, ...). Then export this project as a jar file to any other project. If this is a valid solution, how can I export my Email service Spring mvc project as a jar file? (consider I have external dependencies)
If this is not a good/valid solution, how can I reuse the Email service in different projects with minimum effort? P.S. I am using Maven already in my project.
Upvotes: 0
Views: 653
Reputation: 915
I'd use Maven. Using the pom for the email service you can specify it's dependencies. Build using mvn install to add your jar to the repository.
Then on your future projects add your email service as a dependency. It will pull all required dependencies through.
Upvotes: 1