Journal of A Simple Spring Boot Application

Donnie Z
4 min readMay 30, 2024

--

This article is part of a series of a microservice development. On another article I wrote about core banking features mapped to microservice architecture. This will be a more practical continuation of the previous article.

In attempt to write the next article of the microservice-core banking architecture, I wrote a not so simple dockerized spring boot microservices integrated with other system such as keycloak. However I was overwhelmed as it was too much to write into an article. Now I took step back and do things in smaller pieces. We will start from the very beginning. Friendly reminder, this article will be very basic.

The Beginning

The beginning of developing spring boot application is, nothing other than, Spring Initializr.

For this project I will use Spring Boot 3.1 with spring-web and JPA. I also use lombok to help with boilerplates. Spring rest repositories also imported to help write services for common and uninteresting entities.

The famous spring initializr (anyone notice a typo here?)

Click generate to download the project initial, unzip, remove some files, and initialize git on the directory.

$ git init

$ git add *

$ git commit -m "Init the project"
The most unsuspecting command line

Create a new repository in github, push into it, branch out.

github new repository
$ git remote add origin https://github.com/donniexyz/med-spring-boot-demo.git

$ git push -u origin master

$ git checkout -b develop

Open the project in IntelliJ or other respected IDE, then we are ready to work (some people does not regard non coding activities as programmer’s work; now you know why those development estimates off the mark).

The (Simulated) Requirement

As hypothetical requirement, our project goal is to create a microservice that maintain customer’s bank account. Our business analyst finally ironed something with the client and formally come up with this simplified requirement and use case.

Summary:
* Our client is a bank, and the system will be used by bank to keep track their customer’s saving account
* The system also able to record transactions that happen to the accounts
* Transactions might change balance of the account

Many times we work on something less than this for much bigger scope.

Lets say we got lucky that it is enough for our developers (us) to start coding.

Developing

The development is kept to be as simple as possible, working against temptations to put a complete logic and annotations on every nook and cranny and bugs. I also put spring actuator, Postgresql into pom dependencies.

Testing

After create the db schema, we ask jpa to create the tables of our entities by setting property spring.jpa.hibernate.dll-auto=create then start the application and fire the endpoint using postman.

Notes of findings during test:

  1. Spring Data REST API shows all repositories (I want to expose AccountOwner only)
  2. Able to insert record into AccountOwner table via Spring Data REST API
  3. Attempt to retrieve non existing record produce obscure warning on the log
  4. Call to /actuator/mappings does not shows Spring Data REST API endpoints
Spring Data REST API works for all repositories
Successfully inserted a record into AccountOwner table (using spring REST)
Attempt to retrieve non existing record produce irrelevant warning message
Call to /actuator/mappings shows REST API endpoints are not shown on the mappings.

Conclusion

This simple spring boot application is ready to be our base application for enhancements.

Source Code & References

  1. The source code can be found on github/donniexyz. In addition to source code, it also contains ‘requirement’ and ‘technical notes’ documents, and also postman file and plantuml file (will be added in the future).
  2. Spring Data Rest from spring
  3. Introduction to Spring Data REST from Baeldung

--

--