Tag: springboot

  • How to connect to database from a REST API?

    How to connect to database from a REST API?

    Web applications store data in a database. Doing so , data is stored permanently somewhere so that you can process it later. Even if your application server goes down , you still have the data in your database. Spring makes it easy to connect to any database. You require very minimal code to do this.…

  • How to create a REST API in Spring Boot?

    How to create a REST API in Spring Boot?

    Let’s say you want to create an ecommerce store. And you want to expose REST APIs to the end users to do CRUD(Create, Read , Update and Delete) operations on your store items. You can do this with minimal effort in Spring Boot. Let’s create the REST APIs. Creating a REST API in Spring Boot…

  • How to implement CQRS design pattern in Spring Boot?

    How to implement CQRS design pattern in Spring Boot?

    Contents Problem: Let’s say you run a large scale ecommerce store. You have a large user base who query your system for products much more than they buy them. In other words , your system has more read requests than write requests. And so you would like to handle the high load of read requests…

  • Different ways to do versioning of REST APIs in Spring Boot

    Most of our web apps communicate through HTTP / REST APIs. These APIs can evolve over time. And hence maintaining different versions of them can be helpful. For example , lets say you have been hitting a REST API which returns the different products available on an ecommerce store. The owners decide to launch a…

  • Different ways to call REST APIs in Spring Boot without additional libraries

    In today’s world most modern web apps talk to each other through HTTP APIs. REST API is a popular standard for these HTTP APIs. So calling a REST API from your backend app is a critical functionality. Spring Boot provides multiple abstractions to do this in a simple way. Here are four different ways: Using…

  • How to implement Aspect Oriented Programming in Spring Boot?

    In your web app , Often you need to implement certain logic which is common across different parts of your application. Like purely technical aspects like logging , security etc. You don’t want to repeat this logic in each part of the code. And you also don’t want to clutter your code by including logic…

  • How to query data in Spring Data through Example?

    How to query data in Spring Data through Example?

    One of the frequent operations you perform on a database is retrieving data based on certain criteria. Let’s say you have a table containing developer details , their name , experience and their primary technology skill. And you want your app to be able to query this data. There are many ways to do this.…

  • How to send emails in Spring Boot?

    How to send emails in Spring Boot?

    To send emails using the Spring Boot Email Starter in a Spring Boot application, you can do the following: STEP 1: Add the Spring Boot Email Starter dependency to your project: STEP 2: Configure the connection to the email server in your application.properties file: STEP 3 Inject the JavaMailSender bean into your service and use…

  • How to implement Reactive Programming in Spring Boot?

    How to implement Reactive Programming in Spring Boot?

    Programming comes in different paradigms. For long , we did procedural programming using languages like C where the business logic was executed step by step in a procedural manner. Then came Object Oriented Programming where you modeled your business requirement into domain objects. It represented real world more closely and has been quite successful even…

  • How to implement Transactional Outbox design pattern in Spring Boot Microservices?

    How to implement Transactional Outbox design pattern in Spring Boot Microservices?

    Let’s say you have created a microservice. One of the APIs in the microservice does two operations: How can you make sure both are transactional? In other words if database update fails don’t send the message to the other service and if message sending fails rollback the database update? In Spring you handle transactions using…