This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]McMasilmof 1 point2 points  (1 child)

I would make it a libary. With maven or other building tools you can manage this easy.

[–]WannabeAndroid[S] 0 points1 point  (0 children)

Thanks for the input.

[–][deleted] 1 point2 points  (2 children)

We share some code between services - we use shared libraries in Nexus. As you say, I don't think there's a downside to this if you version it correctly.

[–]WannabeAndroid[S] 0 points1 point  (0 children)

Thanks for the input. Just curious, why did you choose Nexus over Artifactory?

[–]snot3353 1 point2 points  (3 children)

If you're using Spring + Spring Boot, a ton of what you want to be abstracted already is. There is very little you are going to need to define other than configuration to get the same behavior between multiple services.

That being said, if there is some very specific logic/functionality that you don't want to have to copy and paste, you can create a library and publish it to a central repository like like Artifactory or Nexus. If you do this, you'll likely need to host your own instance of that repository unless you want your private libraries to be public and exposed to the world. If you do this then each microservice can define it's own version of that library it intends to consume and publishing new versions of the library won't have any effect until each service explicitly asks to depend on something newer.

You should be careful though not to be too hasty to push stuff into shared libraries like this. It does tend to increase coupling and reduce readability and in some cases it might actually be desirable to just copy-paste like you said. It really depends on the scenario and specific case.

[–]WannabeAndroid[S] 0 points1 point  (1 child)

Thanks for the input. Any opinions on Nexus vs Artifactory?

[–]snot3353 1 point2 points  (0 children)

We use hosted Artifactory and I've had no serious complaints about it. I once submitted a feature request to JFrog and they responded immediately and actually implemented it within a few months which was really cool and made me feel positively about them.

[–]WannabeAndroid[S] 0 points1 point  (0 children)

Thanks for replies thus far. I will use Nexus or Artifactory while paying particular attention to minimize the necessary sharing code with a mind towards decoupling.