Introducing @SpringCloudApplication
If you haven't caught on by now, we plan to split up the system we've built so far so that one microservice focuses on images, and the other on comments. That way, in the future, we can scale each service with the appropriate number of instances based on traffic.
To make this break, let's basically grab all the code from the comments
subpackage, and move it into an entirely different project. We'll call one project images
and the other one comments
.
Before we can copy all that code, we need a project for each. To do so, simply create two new folders, learning-spring-boot-comments
and learning-spring-boot-images
. We could go back to Spring Initializr to create them from scratch, but that's unnecessary. It's much easier to simply copy the existing build file of our monolith into both of our new microservices, and customize the name of the artifact. Since the build.gradle
file is almost identical to the monolith, there's no need to inspect it here.
The new comments...