Demo application to go with my Microservices Blog on the spring.io website. WARNING: Only maven build has been updated. Gradle build still to be done.
Clone it and either load into your favorite IDE or use maven/gradle directly.
Note for gradle users: to make the intructions below build-tool independent, the gradle build copies its artifacts from
Current version (June 2018) v2.0.0 corresponds to Spring Boot 2 and Finchly release train.
WARNING: Only maven build has been updated. Gradle build still to be done.
Previous versions have been tagged and can be accessed using the
Branch button above or using
git checkout <version> - for example
git checkout v1.2.0.
Tagged versions are:
- v2.0.0 - Spring Boot 2.0 and Spring Cloud release-train Finchley
- v1.2.0 corresponds to Spring Boot 1.5 and Spring Cloud release-train Edgeware
- v1.1.0 corresponds to Spring Cloud release-train Brixton
- v1.0.0 corresponds to Spring Cloud release-train Angel.SR6
Using an IDE
You can run the system in your IDE by running the three server classes in order: RegistrationService, AccountsService and WebService. Each is a Spring Boot application using embedded Tomcat. In Spring Tool Suite use
Run As ... Spring Boot App otherwise just run each as a Java application - each has a static
main() entry point.
As discussed in the Blog, open the Eureka dashboard http://localhost:1111 in your browser to see that the
WEB-SERVICE applications have registered. Next open the Demo Home Page http://localhost:3333 in and click one of the demo links.
localhost:3333 web-site is being handled by a Spring MVC Controller in the WebService application, but you should also see logging output from AccountsService showing requests for Account data.
You may find it easier to view the different applications by running them from a command line since you can place the three windows side-by-side and watch their log output
For convenience we are building a 'fat' executble jar whose start-class (main method entry-point) is defined to be in the class
io.pivotal.microservices.services.Main. This application expects a single command-line argument that tells it to run as any of our three servers.
java -jar target/microservices-demo-2.0.0.RELEASE.jar registration|accounts|web
To run the microservices system from the command-line, open three CMD windows (Windows) or three Terminal windows (MacOS, Linux) and arrange so you can view them conveniently.
- In each window, change to the directory where you cloned the demo.
- In the first window, build the application using either
mvn clean packageor
gradle clean assemble. Either way the generated file will be
target/microservices-demo-2.0.0.RELEASE.jar(even if you used gradle).
- In the same window run:
java -jar target/microservices-demo-2.0.0.RELEASE.jar registration
- Switch to the second window and run:
java -jar target/microservices-demo-2.0.0.RELEASE.jar accounts
- In the third window run:
java -jar target/microservices-demo-2.0.0.RELEASE.jar web
- In your favorite browser open the same two links: http://localhost:1111 and http://localhost:3333
You should see servers being registered in the log output of the first (registration) window. As you interact wiht the Web application, you should logging in the both the second and third windows.
For a list of valid accounts refer to the data.sql that is used by the Account Service to set them up.
- In a new window, run up a second account-server using HTTP port 2223:
java -jar target/microservices-demo-2.0.0.RELEASE.jar accounts 2223
- Allow it to register itself
- Kill the first account-server and see the web-server switch to using the new account-server - no loss of service.