Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pom structure for common services built with Spring Boot

I have two projects that contain reusable code for many different services and web apps, such as CommonService and CommonWeb.

I want all my service projects to reuse as much pom configuration as possible from the common service, but I still want to leverage the spring boot starter poms in the common projects to help set them up. What would be the best way to organize the pom hierarchy?

CommonService and CommonWeb both have code, dependencies, and plugins like the AspectJ compiler. Would my AppService add CommonService as a dependency, or as a parent?

like image 720
ant-depalma Avatar asked Jan 19 '26 03:01

ant-depalma


1 Answers

We solved it by having common parent that is inherited from Spring Boot parent. This common parent would be parent for each of projects. This was particularly handy for micro-services architecture.

If you have different types of projects, e.g. HTTP vs messaging service, you can have inheritance hierarchy of POM parents where root is always Spring Boot parent.

If you don't like idea of having inheritance hierarchy of parent POMs, I suggest to analyze Spring Boot project, how they organize POMs. It is very clever, but may be overkill if you don't have a lot of various types of services/projects.

Of course these POMs need to be properly versioned and deployed to some artifact repository as standalone artifacts.

like image 178
luboskrnac Avatar answered Jan 20 '26 17:01

luboskrnac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!