SpringSession

Session Management using Spring Session with JDBC DataStore

In web applications, user session management is very crucial for managing user state. In this article, we are going to learn about what are the approaches we have been following to manage user sessions in a clustered environment and how we can use Spring Session to implement it in a much simpler and more scalable way. Typically in production environments, we will have multiple server nodes with a load balancer in front of them and all the client traffic will be coming through the load balancer to one of the server nodes. So we need some mechanism to make the

Continue reading »

CI/CD for SpringBoot applications using Travis-CI

In this article we are going to learn how we can use Travis CI for Continuous Integration and Continuous Deployment (CI/CD) of a SpringBoot application. We will learn how to run maven build goals, perform test coverage validation using JaCoCo plugin, Code Quality checks using SonarCloud, build Docker image and push it to DockerHub and finally deploy it to Heroku. The source code for this article is at https://github.com/sivaprasadreddy/freelancer-kit Last week I was talking to my friend about how easy it became to build a Java application and deploy it using SpringBoot. During the discussion one point came out about how

Continue reading »

Select ALL starters on Spring Initializer (http://start.spring.io)

If you are working on Spring Boot then you most probably aware of Spring Initializer (http://start.spring.io) which is an online spring boot application generator. You can select the starters that you want to use and then generate the application. If you notice that there is no SELECT ALL option to select all the starters. Who would do that insane thing of selecting all the starters for an application??!!??? But, i would like to have the SELECT ALL option for one single reason: I can download all the dependencies ahead of time when I have good internet connectivity so that I

Continue reading »

Spring Cloud Tutorials – Auto Refresh Config Changes using Spring Cloud Bus

Problem In the previous article Introduction to Spring Cloud Config Server (http://sivalabs.in/2017/08/spring-cloud-tutorials-introduction-to-spring-cloud-config-server/) we have seen how to use Spring Cloud Config Server. But, the problem is to reload the config changes in Config Client applications we need to trigger /refresh endpoint manually. This is not practical and viable if you have large number of applications. Solution Spring Cloud Bus module can be used to link multiple applications with a message broker and we can broadcast configuration changes. Let us see how we can use RabbitMQ as message broker and connect multiple applications to receive the configuration change events and refresh

Continue reading »

Spring Cloud Tutorials – Introduction to Spring Cloud Config Server

Problem SpringBoot provides lot of flexibility in externalizing configuration properties via properties or YAML files. We can also configure properties for each environment (dev, qa, prod etc) separately using profile specific configuration files such as application.properties, application-dev.properties, application-prod.properties etc. But once the application is started we can not update the properties at runtime. If we change the properties we need to restart the application to use the updated configuration properties. Also, in the context of large number of MicroService based applications, we want the ability to configure and manage the configuration properties of all MicroServices from a centralized place. Solution

Continue reading »

Getting Started with SpringBoot in Intellij IDEA Community Edition

We can use Intellij IDEA Community Edition for working with SpringBoot applications as we don’t need support for configuring servers like Tomcat, Wildlfy etc and can simply run the applications by running main() method. However, there is no provision in Intellij IDEA Community Edition to create SpringBoot application directly, the way it supports in Ultimate Edition. We can go to http://start.spring.io/ and generate the project and then import into our IDE. But it would be nice to be able to create the SpringBoot project from IDE itself. One simple alternative I found to circumvent this problem is by using Project

Continue reading »

Update on SpringBoot : Learn By Example book

I would like to let you know that I have updated/added the following sections to my SpringBoot : Learn By Example book. Additions to existing chapters: Working with Multiple Databases Exposing JPA entities with bi-directional references through RESTful services In some of our applications we need to work with multiple databases. For example, we may have a primary database and a reporting database where most the application uses primary database and the application reports will be generated out of reporting database data. The section Working with Multiple Databases explains how to configure multiple databases while using JPA in a SpringBoot

Continue reading »

My New Book SpringBoot : Learn By Example Published Today

I am happy to announce that my new book SpringBoot : Learn By Example  got published today on Leanpub. SpringBoot : Learn By Example   What is SpringBoot? Spring is one of the most popular Java frameworks out there to build web and enterprise application. Spring supports variety of configuration approaches (XML, Annotations, JavaConfig etc) and properly configuring Spring applications become a bit tedious and repetitive process. To avoid these problems Spring team introduced SpringBoot to address the complexity of configuring Spring application. SpringBoot is an opinionated approach to configure Spring based applications. SpringBoot automatically configures the application components based

Continue reading »

My Review of Sanjay Patel’s Spring Course

Spring is the most popular Java framework for building web and enterprise applications. There are plenty of official documentation, books, and Training Courses available for Spring framework on web. I got an opportunity to review Sanjay Patel‘s Spring Course Material which is divided into 3 modules. http://www.naturalprogrammer.com/spring-tutorial/ The total course is divided into 3 modules covering various aspects of web application development using Spring/SpringBoot framework. Module I : Spring Framework 4 And Dependency Injection For Beginners Module II : Spring Framework for the Real World Module III : Spring Framework REST API Development Module I: Spring Framework 4 and Dependency

Continue reading »

Creating Custom SpringBoot Starter for Twitter4j

SpringBoot provides lot of starter modules to get up and running quickly. SpringBoot’s auto-configure mechanism takes care of configuring SpringBeans on our behalf based on various criteria. In addition to the springboot starters that comes out-of-the-box provided by Core Spring Team, we can also create our own starter modules. In this post we will look into how to create a custom SpringBoot starter. To demonstrate it we are going to create twitter4j-spring-boot-starter which will auto-configure Twitter4J beans. To accomplish this, we are going to create:  twitter4j-spring-boot-autoconfigure module which contains Twitter4J AutoConfiguration bean definitions  twitter4j-spring-boot-starter module which pulls in twitter4j-spring-boot-autoconfigure and

Continue reading »