Skip to main content

Posts

Reactive Spring - CRUD with MongoDB

Greetings! When we learn something, it is good to have something to play with. Now is the time to connect with a database. Working with Reactive Programming is fun but it brings extra challenges. Connecting to a database is such a challenge as we can't use blocking drivers. Lucky for us, Spring comes with Data Repository for MongoDB. Assumptions: You are comfortable with Spring Boot REST You have installed or have access to the MongoDB database The completed project is here -  reactive-super-heroes What to expect? We will follow Spring's usual layers. The main difference is we are using a Reactive Repository instead of the usual blocking repository. We will build a simple REST application with CRUD operations to store superheroes. Create the project Add database connection Create entity (document), dtos Create repository Create service Create controller Demo Create the project Go to start.spring.io and create a project with the below dependencies. S

AWS Spring - Deploy Spring Boot application to AWS EC2

Greetings! AWS and Spring are two of the most needed skills Java developer needs these days. It is no fun to just learn theory. Let's host our tiny Spring backed application in AWS. Assumption : You are comfortable with Spring, AWS but exploring how to deploy. In this basic setup, we are going to use the easiest way in contrast to learning. We had a running system in this way which had around 8~10 microservices. I missed those days anyway. It is very primitive but it works! Steps Let's define what we are going to do. Create an EC2 instance Create Spring Boot app Setup EC2 Copy Spring boot application into EC2 and run Create an EC2 instance I assume you already know this step. However, there are a few things to note. Make sure to download your keypair (mykeypair.pem) and set the correct permission (chmod +400) Security group - Add 2 rules to allow ssh (port 22) and HTTP access with port 8080 Create a Spring boot applicatio

Reactive Spring - Getting Started

Greetings! Reactive programming is very popular now. Every passionate Java developer wants to try out it with Webflux which is Spring's way of reactive web development.  In this first tutorial, I am not trying to explain Reactive Programming or Spring WebFlux or anything in detail. Instead, I would like to just play with it. Let's practice a little then come to theory on another day. Assumption : You know how to create and run a Spring Boot application. Warning : Do not try hard, just play with it. Full source code of this article -  reactive-spring-hello Create the project Go to Spring initializer ( https://start.spring.io/ ) and fill out project metadata. Add the below dependencies. Spring Reactive Web, Lombok Download and open the project with your desired IDE. Say hello Reactively Let's quickly create an endpoint (Controller) and add the below contents. Compile and run it. http://localhost:8080/mono, http://localhost:8080/flux package com.slmanju.reactivespringhello.