<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rajendra🙏🏼👇🏽</title>
    <description>The latest articles on DEV Community by Rajendra🙏🏼👇🏽 (@nagarajendra).</description>
    <link>https://dev.to/nagarajendra</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F274605%2Ff8dbb804-5073-4bdb-be7a-fae555fa203a.jpg</url>
      <title>DEV Community: Rajendra🙏🏼👇🏽</title>
      <link>https://dev.to/nagarajendra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nagarajendra"/>
    <language>en</language>
    <item>
      <title>Basics of Resilience4j with spring boot</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Fri, 27 Mar 2020 03:43:51 +0000</pubDate>
      <link>https://dev.to/nagarajendra/basics-of-resilience4j-with-spring-boot-4dk8</link>
      <guid>https://dev.to/nagarajendra/basics-of-resilience4j-with-spring-boot-4dk8</guid>
      <description>&lt;h2&gt;
  
  
  What is a Circuit Breaker pattern?
&lt;/h2&gt;

&lt;p&gt;The circuit breaker pattern is something that can prevent from repeatedly trying to call a service or a function that will likely fail and save CPU cycles.&lt;/p&gt;

&lt;p&gt;It is pretty common for a software service to call remote software service and the remote service can fail or not respond as expected and this is pretty common in a microservice architecture when you have hundreds of clients calling the service which is failing eventually all the resources get used up, that is why it is a best practice to implement circuit breaker pattern in those scenarios.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does Circuit Breaker work?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Circuit Breaker&lt;/strong&gt; has three states &lt;strong&gt;Closed&lt;/strong&gt; State, &lt;strong&gt;Open&lt;/strong&gt; State, &lt;strong&gt;Half Open&lt;/strong&gt; State. The image below shows how the flow from one state to another changes. The Circuit Breaker will be in the &lt;strong&gt;Closed&lt;/strong&gt; state when everything is running as expected when failure starts coming it waits until the set &lt;strong&gt;threshold limit&lt;/strong&gt; is reached then goes to &lt;strong&gt;Open&lt;/strong&gt; state. While in Open states no calls will be going to failing remote service until certain wait time, then it goes to &lt;strong&gt;Half-Open&lt;/strong&gt; state, in this stage reduced amount of calls goes to remote service to make sure the calls are successful, &lt;strong&gt;IF&lt;/strong&gt; the calls are responding as expected it will go to &lt;strong&gt;Closed&lt;/strong&gt; state or it goes back to &lt;strong&gt;Open&lt;/strong&gt; state avoiding calls to failing remote service.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5CZs7j96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/312kak912zmaqfc2dx8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5CZs7j96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/312kak912zmaqfc2dx8e.png" alt="Circuit Breaker Pattern"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Resilience4j?
&lt;/h2&gt;

&lt;p&gt;Resilience4j is a lightweight, easy-to-use fault tolerance library designed for Java 8 and functional programming, it is a lightweight as it doesn't depend on any other external libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you are a video person here is the video tutorial&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt; &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Hacker Heap&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/fkQHtw35alY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation with Spring boot2
&lt;/h2&gt;

&lt;p&gt;Add the dependency to &lt;strong&gt;pom.xml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;io.github.resilience4j&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;resilience4j-spring- 
                            boot2&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;1.3.1&amp;lt;/version&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Add the required configurations to application.yml file or application.properties file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resilience4j:
  circuitbreaker:
    configs:
      default:
        registerHealthIndicator: true
        slidingWindowSize: 10
        minimumNumberOfCalls: 5
        permittedNumberOfCallsInHalfOpenState: 3
        automaticTransitionFromOpenToHalfOpenEnabled: true
        waitDurationInOpenState: 5s
        failureRateThreshold: 50
        eventConsumerBufferSize: 10
        recordExceptions:
                - org.springframework.web.client.HttpServerErrorException
                - java.util.concurrent.TimeoutException
                - java.io.IOException
    instances:
      mainService:
        baseConfig: default
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above is the base configuration for resilience4j, &lt;strong&gt;waitDurationInOpenState&lt;/strong&gt; is how much time the circuit breaker will be in Open state before it goes to Half-Open state .&lt;br&gt;
&lt;strong&gt;failureRateThreshold&lt;/strong&gt; sets the threshold limit before it goes to the open state.&lt;br&gt;
&lt;strong&gt;recordExceptions&lt;/strong&gt; records the type of exception on which you want your circuit breaker to be activated.&lt;br&gt;
You can have multiple profiles for different service calls or operations, the above configuration has just one profile &lt;strong&gt;default&lt;/strong&gt;, which is assigned to the &lt;strong&gt;mainService&lt;/strong&gt; declared in the below class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.springsleuth.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;

@RestController
public class MainServiceController {

    private static final Logger LOGGER = LoggerFactory.getLogger(MainServiceController.class);

    private static final String MAIN_SERVICE = "mainService";

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


    @GetMapping("/getSleuthTest")
    @ResponseStatus(HttpStatus.OK)
    @CircuitBreaker(name = MAIN_SERVICE, fallbackMethod="testFallBack")
    public ResponseEntity&amp;lt;String&amp;gt; getSleuthTest(){
        LOGGER.info("I'm here in main service calling service one");
        String response = restTemplate.getForObject("http://localhost:8081/serviceOne", String.class);
        return new ResponseEntity&amp;lt;String&amp;gt;(response, HttpStatus.OK);

    }


    private  ResponseEntity&amp;lt;String&amp;gt; testFallBack(Exception e){
        return new ResponseEntity&amp;lt;String&amp;gt;("In fallback method", HttpStatus.INTERNAL_SERVER_ERROR);
    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above class, we activated circuit breaker using @CircuitBreaker annotations, it has two parameters.&lt;br&gt;
1) &lt;strong&gt;service name&lt;/strong&gt;, which is the service name defined in the config file (mainService) with default profile.&lt;br&gt;
2) &lt;strong&gt;fallBackMethod&lt;/strong&gt;, which is called when an error occurs, fallBackMethod is optional.&lt;/p&gt;

</description>
      <category>resilience4j</category>
      <category>springboot</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Spring Cloud Sleuth Tutorial With Zipkin</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 16 Mar 2020 03:59:39 +0000</pubDate>
      <link>https://dev.to/nagarajendra/spring-cloud-sleuth-tutorial-with-zipkin-22lc</link>
      <guid>https://dev.to/nagarajendra/spring-cloud-sleuth-tutorial-with-zipkin-22lc</guid>
      <description>&lt;p&gt;As microservice architecture has become a standard for all the latest distributed systems, the tracing of the calls from one microservice to others has been a challenging thing for a while.&lt;/p&gt;

&lt;p&gt;To solve this Sprig Cloud introduced Spring Sleuth which borrows heavily from dapper. Spring sleuth adds traceID and spanID to the logs so it makes easy to trace a microservice/ web service call.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will implement Spring Sleuth and integrate with Zipkin which is a distributed tracing system that provides a UI that lets us search the transactions using traceID and also view the dependency diagram which shows how many traced transactions went through each microservice.&lt;/p&gt;

&lt;p&gt;Let's create three spring boot microservice namely &lt;strong&gt;ServiceOne&lt;/strong&gt; &lt;strong&gt;ServiceTwo&lt;/strong&gt; &lt;strong&gt;ServiceThree&lt;/strong&gt;.&lt;br&gt;
In each of the services add the dependencies for &lt;strong&gt;Spring Sleuth&lt;/strong&gt;, &lt;strong&gt;Zipkin&lt;/strong&gt;, and &lt;strong&gt;spring boot stater web&lt;/strong&gt;, the resultant  &lt;strong&gt;pom.xml&lt;/strong&gt; file should like below.&lt;/p&gt;

&lt;p&gt;If you are a video person here is the video tutorial&lt;/p&gt;

&lt;p&gt;Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Oxfk3gns5qo"&gt;
&lt;/iframe&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;
    &amp;lt;parent&amp;gt;
        &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;spring-boot-starter-parent&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;2.2.5.RELEASE&amp;lt;/version&amp;gt;
        &amp;lt;relativePath/&amp;gt; &amp;lt;!-- lookup parent from repository --&amp;gt;
    &amp;lt;/parent&amp;gt;
    &amp;lt;groupId&amp;gt;com.example&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;MainService&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;0.0.1-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;name&amp;gt;Service One&amp;lt;/name&amp;gt;
    &amp;lt;description&amp;gt;Spring Boot With Spring Sleuth&amp;lt;/description&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;java.version&amp;gt;1.8&amp;lt;/java.version&amp;gt;
        &amp;lt;spring-cloud.version&amp;gt;Hoxton.SR3&amp;lt;/spring-cloud.version&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
    &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-web-services&amp;lt;/artifactId&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-cloud-starter-sleuth&amp;lt;/artifactId&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-cloud-starter-zipkin&amp;lt;/artifactId&amp;gt;
        &amp;lt;/dependency&amp;gt;

        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-test&amp;lt;/artifactId&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;exclusions&amp;gt;
                &amp;lt;exclusion&amp;gt;
                    &amp;lt;groupId&amp;gt;org.junit.vintage&amp;lt;/groupId&amp;gt;
                    &amp;lt;artifactId&amp;gt;junit-vintage-engine&amp;lt;/artifactId&amp;gt;
                &amp;lt;/exclusion&amp;gt;
            &amp;lt;/exclusions&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

    &amp;lt;dependencyManagement&amp;gt;
        &amp;lt;dependencies&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;spring-cloud-dependencies&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${spring-cloud.version}&amp;lt;/version&amp;gt;
                &amp;lt;type&amp;gt;pom&amp;lt;/type&amp;gt;
                &amp;lt;scope&amp;gt;import&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
        &amp;lt;/dependencies&amp;gt;
    &amp;lt;/dependencyManagement&amp;gt;

    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;

&amp;lt;/project&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Add a RestController for three services each having GET endpoints /serviceOne /serviceTwo /serviceThree as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.springsleuth.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ServiceOneController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceOneController.class);

    @Autowired
    private RestTemplate restTemplate;

    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    @GetMapping("/serviceOne")
    @ResponseStatus(HttpStatus.OK)
    public ResponseEntity&amp;lt;String&amp;gt; getSleuthTest(){
        LOGGER.info("I'm here in service calling service two");
        String response = restTemplate.getForObject("http://localhost:8081/serviceTwo", String.class);
        return new ResponseEntity&amp;lt;String&amp;gt;(response, HttpStatus.OK);

    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Spring Sleuth has the capability to integrate the same traceId to the microservice chain if the services are called using RestTemplate and have been Autowired, create the restTemplate object like the one in the above example and auto-wire so that spring handles the dependency injection.&lt;/p&gt;

&lt;p&gt;We have the endpoint for serviceOne is ready, and create the endpoints for serviceTwo and serviceThree similar to the above serviceOne example below is the code for serviceTwo and serviceThree controllers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.springsleuth.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ServiceTwoController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceTwoController.class);

    @Autowired
    private RestTemplate restTemplate;


    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


    @GetMapping("/serviceTwo")
    @ResponseStatus(HttpStatus.OK)
    public ResponseEntity&amp;lt;String&amp;gt; getServiceTwo() throws Exception {
        LOGGER.info("Here inside service two ");
        String response =  restTemplate.getForObject("http://localhost:8080/serviceThree", String.class);
        return new ResponseEntity&amp;lt;String&amp;gt;(response, HttpStatus.OK);
    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.springsleuth.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class ServiceThreeController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceThreeController.class);

    @Autowired
    private RestTemplate restTemplate;


    @Bean
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }


    @GetMapping("/serviceThree")
    @ResponseStatus(HttpStatus.OK)

    public ResponseEntity&amp;lt;String&amp;gt; getServiceThree() throws Exception {
        LOGGER.info("Here inside service Three ");
        return new ResponseEntity&amp;lt;String&amp;gt;("Success calling Spring Sleuth", HttpStatus.OK);
    }

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Application Properties
&lt;/h2&gt;

&lt;p&gt;Since we will be running all the three microservices on the same machine we will have them run on different ports, set the ports in the application.properties file of the respective projects. The appliction.properties file will have two attributes service.name and server.port like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spring.application.name=serviceOne
server.port=8080
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Zipkin Setup
&lt;/h2&gt;

&lt;p&gt;Zipkin is an open-source project that you can download using the below command, more about Zipkin can be found at  Zipkin.io.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -sSL https://zipkin.io/quickstart.sh | bash -s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once downloaded run Zipkin jar using the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar zipkin.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Zipkin  UI can be seen at localhost:9094/zipkin, which looks like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_AkeWHOP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/za2hf5xsy08lcbanirgw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_AkeWHOP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/za2hf5xsy08lcbanirgw.png" alt="Zipkin UI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's start all the three microservices on different ports, and hit the serviceOne endpoint. Use the log below with [serviceName, traceId, spanId, True/False] these are added by spring sleuth and we have nothing to do.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2020-03-14 23:31:05.084  INFO [serviceOne,2ed9f774e90e9450,2ed9f774e90e9450,true] 17903 --- [nio-8082-exec-2] c.s.d.controller.MainServiceController   : I'm here in main service calling service one

2020-03-14 23:31:05.181  INFO [serviceTwo,2ed9f774e90e9450,4bc477a78961a834,true] 17902 --- [nio-8081-exec-1] c.s.d.controller.ServiceTwoController    : Here inside service Two 

2020-03-14 23:31:05.304  INFO [serviceThree,2ed9f774e90e9450,dbc9d06429c2394a,true] 17901 --- [nio-8080-exec-1] c.s.d.controller.ServiceOneController    : Here inside service Three 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you observe the above logs all the logs for three microservices has the same traceID for the call, now go back to zipkin UI and search with the traceID and you we the calls going from one service to other like below, it also shows the time taken for each call.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MkNuVZR_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4rudn05m7hm7wfhje88j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MkNuVZR_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4rudn05m7hm7wfhje88j.png" alt="Zipkin UI Showing Tracing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are a video person here is the video tutorial&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Oxfk3gns5qo"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>springcloudsleuth</category>
      <category>springcloud</category>
      <category>java</category>
    </item>
    <item>
      <title>Intro to GraphQL With Apollo Server</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Tue, 28 Jan 2020 00:46:49 +0000</pubDate>
      <link>https://dev.to/nagarajendra/intro-to-graphql-with-apollo-server-425j</link>
      <guid>https://dev.to/nagarajendra/intro-to-graphql-with-apollo-server-425j</guid>
      <description>&lt;p&gt;This is a basic introduction to GraphQL with Apollo Server, originally posted on my Youtube Channel.&lt;/p&gt;

&lt;p&gt;Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>graphql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Netflix Eureka Server And Client Setup With Spring Boot</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Tue, 21 Jan 2020 04:12:48 +0000</pubDate>
      <link>https://dev.to/nagarajendra/netflix-eureka-server-and-client-setup-with-spring-boot-3j9n</link>
      <guid>https://dev.to/nagarajendra/netflix-eureka-server-and-client-setup-with-spring-boot-3j9n</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Overview&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We will set up a Eureka server (service registry used to register multiple services/microservices).&lt;/li&gt;
&lt;li&gt;We will set up multiple Eureka clients(REST services that register to Eureka Server).&lt;/li&gt;
&lt;li&gt;We will do client-side load balancing and service discovery through Eureka.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the video tutorial. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/o2QqoQJGeNY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Setting up Eureka Server&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The dependency required to set up a eureka server is &lt;strong&gt;&lt;em&gt;"spring-cloud-starter-netflix-eureka-client"&lt;/em&gt;&lt;/strong&gt; along with spring-boot-starter-parent. you can generate the code by going to &lt;a href="https://start.spring.io/"&gt;&lt;strong&gt;&lt;em&gt;https://start.spring.io/&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;, and provide the group id, artifact id and provide the required dependencies as shown below, and click on generate which will generate the sample code with dependency added to your &lt;strong&gt;&lt;em&gt;pom.xml&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uX0nz38K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vup0hkz68tr3tynl7uix.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uX0nz38K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/vup0hkz68tr3tynl7uix.png" alt="Spring Initialzr"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The corresponding &lt;strong&gt;&lt;em&gt;pom.xml&lt;/em&gt;&lt;/strong&gt; should look like the below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;
    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;
    &amp;lt;parent&amp;gt;
        &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
        &amp;lt;artifactId&amp;gt;spring-boot-starter-parent&amp;lt;/artifactId&amp;gt;
        &amp;lt;version&amp;gt;2.2.3.RELEASE&amp;lt;/version&amp;gt;
        &amp;lt;relativePath/&amp;gt; &amp;lt;!-- lookup parent from repository --&amp;gt;
    &amp;lt;/parent&amp;gt;
    &amp;lt;groupId&amp;gt;com.example&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;eurekaserver&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;0.0.1-SNAPSHOT&amp;lt;/version&amp;gt;
    &amp;lt;name&amp;gt;eurekaserver&amp;lt;/name&amp;gt;
    &amp;lt;description&amp;gt;Demo project for Spring Boot&amp;lt;/description&amp;gt;

    &amp;lt;properties&amp;gt;
        &amp;lt;java.version&amp;gt;1.8&amp;lt;/java.version&amp;gt;
        &amp;lt;spring-cloud.version&amp;gt;Hoxton.SR1&amp;lt;/spring-cloud.version&amp;gt;
    &amp;lt;/properties&amp;gt;

    &amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-cloud-starter-netflix-eureka-server&amp;lt;/artifactId&amp;gt;
        &amp;lt;/dependency&amp;gt;

        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-test&amp;lt;/artifactId&amp;gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;
            &amp;lt;exclusions&amp;gt;
                &amp;lt;exclusion&amp;gt;
                    &amp;lt;groupId&amp;gt;org.junit.vintage&amp;lt;/groupId&amp;gt;
                    &amp;lt;artifactId&amp;gt;junit-vintage-engine&amp;lt;/artifactId&amp;gt;
                &amp;lt;/exclusion&amp;gt;
            &amp;lt;/exclusions&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

    &amp;lt;dependencyManagement&amp;gt;
        &amp;lt;dependencies&amp;gt;
            &amp;lt;dependency&amp;gt;
                &amp;lt;groupId&amp;gt;org.springframework.cloud&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;spring-cloud-dependencies&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;${spring-cloud.version}&amp;lt;/version&amp;gt;
                &amp;lt;type&amp;gt;pom&amp;lt;/type&amp;gt;
                &amp;lt;scope&amp;gt;import&amp;lt;/scope&amp;gt;
            &amp;lt;/dependency&amp;gt;
        &amp;lt;/dependencies&amp;gt;
    &amp;lt;/dependencyManagement&amp;gt;

    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;

&amp;lt;/project&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once you have the project open the main Springboot Class with annotation &lt;strong&gt;&lt;em&gt;@SpringbootApplication&lt;/em&gt;&lt;/strong&gt; and add the annotation &lt;strong&gt;&lt;em&gt;@EnableEurekaServer&lt;/em&gt;&lt;/strong&gt;, the class should look like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.eurekaserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaserverApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaserverApplication.class, args);
    }

}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The last step in setting up the server is adding the &lt;strong&gt;&lt;em&gt;application.yml&lt;/em&gt;&lt;/strong&gt; file which will have eureka relate properties when you start the application with &lt;strong&gt;&lt;em&gt;@EnableEurekaServer&lt;/em&gt;&lt;/strong&gt; annotation it will look for &lt;strong&gt;&lt;em&gt;bootstrap.yml&lt;/em&gt;&lt;/strong&gt; file if not found it will look for &lt;strong&gt;&lt;em&gt;application.yml&lt;/em&gt;&lt;/strong&gt; file for the properties the yml file should look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server:
  port: 9090

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false
    serviceUrl:
      defaultZone: http://localhost:9090/eureka/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above properties yaml file defines the eureka &lt;strong&gt;&lt;em&gt;defaultZone&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;serviceUrl&lt;/em&gt;&lt;/strong&gt; where eureka is supposed to run. &lt;strong&gt;&lt;em&gt;register-with-eureka&lt;/em&gt;&lt;/strong&gt; property is set to false as we don't want to register Eureka Server to itself.&lt;br&gt;
Once everything is the project structure should look like the below image&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z0qcQhNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/13vwu3u7tkwhrsawtpw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z0qcQhNW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/13vwu3u7tkwhrsawtpw2.png" alt="Eureka Server Project Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Go ahead and start the spring boot application, the eureka server should be up in whatever port you mentioned in &lt;strong&gt;&lt;em&gt;application.yml&lt;/em&gt;&lt;/strong&gt; file in this case eureka server will be up at &lt;strong&gt;&lt;em&gt;localhost:9090&lt;/em&gt;&lt;/strong&gt; and will look like below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YA58lv7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m4midsz73tu1ba7byshw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YA58lv7H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/m4midsz73tu1ba7byshw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ola, we have set up the eureka server.&lt;/p&gt;

&lt;p&gt;Now we will go ahead and create two clients named client1 and client2 from the spring initializer like the above with adding one more dependency Eureka Discovery Client, as shown below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VO3Iu8dQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wlyxlt119dia4w9pl1gu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VO3Iu8dQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/wlyxlt119dia4w9pl1gu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once we have both the projects created we will go ahead and add the annotation &lt;strong&gt;&lt;em&gt;@EnableDiscoveryClient&lt;/em&gt;&lt;/strong&gt; on the root &lt;strong&gt;&lt;em&gt;SprintBootApplication&lt;/em&gt;&lt;/strong&gt; class as shown below for both the clients &lt;strong&gt;&lt;em&gt;Client1&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;Client2&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.client2;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class Client2Application {

    public static void main(String[] args) {
        SpringApplication.run(Client2Application.class, args);
    }

}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Similarly, we need to update the application.yml file as below providing the required eureka config details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spring:
  application:
    name: 'client1'
server:
  port: 8081

eureka:
  instance:
    hostname: ${vcap.application.uris[0]:localhost}
    prefer-ip-address: true
    lease-renewal-interval-in-seconds: 10
    lease-expiration-duration-in-seconds: 20
  client:
    service-url:
      defaultZone: http://localhost:9090/eureka

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In the above code, we have provided the spring application name and eureka client service URL where the eureka server resides, so once you start the client it will look into the service URL and tries to register itself. The property *&lt;strong&gt;&lt;em&gt;lease-renewal-interval-in-seconds: 10 &amp;amp; lease-expiration-duration-in-seconds: 20&lt;/em&gt;&lt;/strong&gt;* lets the Eureka Server when to check for the health of the client. Once you made these changes go ahead and start both the clients. &lt;/p&gt;

&lt;p&gt;If you go back to Eureka Server you will now be able to see the two clients registered with names &lt;strong&gt;&lt;em&gt;CLIENT1&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;CLIENT2&lt;/em&gt;&lt;/strong&gt; as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aN3L2L7Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dfuwkkt7pn5exgu1sjsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aN3L2L7Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/dfuwkkt7pn5exgu1sjsl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now the setup has been completed the two clients can talk to each with using the service discovery.&lt;/p&gt;

&lt;p&gt;Here is the video tutorial. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/o2QqoQJGeNY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Base Java Part 3 (Datatypes In Java)</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 13 Jan 2020 12:55:05 +0000</pubDate>
      <link>https://dev.to/nagarajendra/base-java-part-3-datatypes-in-java-32ko</link>
      <guid>https://dev.to/nagarajendra/base-java-part-3-datatypes-in-java-32ko</guid>
      <description>&lt;p&gt;Here is the video tutorial. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/dsMPRdgSAko"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is a Datatype?&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A data type is an attribute of data that tells the compiler or interpreter how the programmer intends to use the data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Data types in Java programming language&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two different sets of data types in Java &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Primitive Datatypes&lt;/li&gt;
&lt;li&gt;Non Primitive Datatypes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The below image depicts different data types in java&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OB6y0fa---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q7j0puttecv31anaa64n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OB6y0fa---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/q7j0puttecv31anaa64n.png" alt="Java Datatypes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Java programming language is statically-typed, which means that all variables must first be declared before they can be used. This involves stating the variable's type and name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;boolean:&lt;/em&gt;&lt;/strong&gt; is used to store true or false value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;byte, short, int, long:&lt;/em&gt;&lt;/strong&gt; is used to store whole numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;float, double:&lt;/em&gt;&lt;/strong&gt; is used to store fractional numbers.&lt;/p&gt;

&lt;p&gt;The below table depicts different datatypes and the size of those datatypes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FvPGFt2j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/beba61b0jn4x718q7b1a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FvPGFt2j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/beba61b0jn4x718q7b1a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The below class has all these datatypes defined and declared.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.test.java;

public class BasicDataTypes {

    static byte i = 127;
    static short j = 3456;
    static int k = 24233534;
    static long l = 34564;
    static float fl = 35325432;
    static double db = 34523763;
    static boolean b = true;
    static char c = 'c';

    static String testString = "Hello World";


    public static void main(String [] args) {
        char[] testCharString = new char[11];
        testCharString[0] = 'h';
        testCharString[1] = 'e';
        testCharString[2] = 'l';
        testCharString[3] = 'l';
        testCharString[4] = 'o';
        testCharString[5] = ' ';
        testCharString[6] = 'w';
        testCharString[7] = 'o';
        testCharString[8] = 'r';
        testCharString[9] = 'l';
        testCharString[10] = 'd';

        System.out.println("Default value of byte is ---&amp;gt; "+i);
        System.out.println("Default value of short is ---&amp;gt; "+j);
        System.out.println("Default value of int is ---&amp;gt; "+k);
        System.out.println("Default value of long is ---&amp;gt; "+l);
        System.out.println("Default value of float is ---&amp;gt; "+fl);
        System.out.println("Default value of double is ---&amp;gt; "+db);
        System.out.println("Default value of boolean is ---&amp;gt; "+b);
        System.out.println("Default value of char is ---&amp;gt; "+c);
        System.out.println("Default value of String is ---&amp;gt; "+testString);
        System.out.println("Default value of char is ---&amp;gt; "+String.valueOf(testCharString));


    }

}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is the video tutorial. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/dsMPRdgSAko"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Base Java Part 2 (Class vs Object)</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 06 Jan 2020 13:04:32 +0000</pubDate>
      <link>https://dev.to/nagarajendra/base-java-part-2-class-vs-object-m64</link>
      <guid>https://dev.to/nagarajendra/base-java-part-2-class-vs-object-m64</guid>
      <description>&lt;p&gt;This is part of the Base Java series, in this part 2 we discuss&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Difference between Class &amp;amp; Object.&lt;/li&gt;
&lt;li&gt;How to create an object in Java.&lt;/li&gt;
&lt;li&gt;Talk about constructor in Java.&lt;/li&gt;
&lt;li&gt;Different ways to create an object in Java.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the full video of the part 2 Base Java Series. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/d00Ww1OsT6E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Class&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A class is a template or a set of instructions to build a specific type of object, it determines how an object behaves and what the object contains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Object&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Objects represent real-life entities, Object determines the behavior of the class, the object has a state, behavior, and identity. Object implements the state and behavior in the form of variables and methods and requires some memory allocated.&lt;/p&gt;

&lt;p&gt;Let's take the example, you want to build a car management system&lt;/p&gt;

&lt;p&gt;You will define car class which will have a name, type, color, and functions like running, autopilot, stopping, etc.&lt;/p&gt;

&lt;p&gt;The objects are tesla, accord, Lexus, etc.. as shown in the below image&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SdVeG5Yh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kcfjpm7e67kcf3ekcba6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SdVeG5Yh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kcfjpm7e67kcf3ekcba6.png" alt="Class Object"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Different ways to create an Object&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We create an object in Java in multiple ways&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;"new" keyword.&lt;/li&gt;
&lt;li&gt;"newInstance()" method.&lt;/li&gt;
&lt;li&gt;using "Clone()" method.&lt;/li&gt;
&lt;li&gt;using "ClassLoader".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The below Car Class and SampleJavaProject Class demonstrates these 4 ways to create Objects in Java.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Car.java&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.test.java;

public class Car implements Cloneable{

    private String Name;

    private String Type;

    private String Color;

    public Car() {
        super();
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }


    public  Car(String name, String type, String color) {
        this.Name = name;
        this.Type = type;
        this.Color = color;
    }

    @Override
    public String toString() {
        return "Car [Name=" + Name + ", Type=" + Type + ", Color=" + Color + "]";
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getType() {
        return Type;
    }

    public void setType(String type) {
        Type = type;
    }

    public String getColor() {
        return Color;
    }

    public void setColor(String color) {
        Color = color;
    }


}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;SampleJavaProject.java&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.test.java;

public class SampleJavaProject {

    public static void main(String [] args) {

        Car accord = new Car("Accord","2WD","Blue");
        Car tesla = new Car("Tesla","4WD","White");
        Car camry = new Car("Camry","2WD","red");
        try {
        Class clsClass = Class.forName("com.test.java.Car");
        Car tesla2 = (Car)clsClass.newInstance();
        tesla2.setColor("grey");
        tesla2.setName("model3");
        tesla2.setType("AWD");
        System.out.println("tesla2----&amp;gt;"+tesla2.toString());
        }catch(Exception e) {
            e.printStackTrace();
        }
        try {
        Car obj1 = new Car();
        Car obj2 = (Car) obj1.clone();
        obj2.setColor("purple");
        obj2.setName("cloenCar");
        obj2.setType("NWD");
        System.out.println("clone car-----&amp;gt;"+obj2.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }

        Car classLoaderObjeCar = null;
        try {
            classLoaderObjeCar = (Car) new SampleJavaProject().getClass().getClassLoader().loadClass("com.test.java.Car").newInstance();
            classLoaderObjeCar.setColor("purple");
            classLoaderObjeCar.setName("classloader car");
            classLoaderObjeCar.setType("MWD");
            System.out.println("Class Loader car-----&amp;gt;"+classLoaderObjeCar.toString());
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("Accord----&amp;gt;"+accord.toString());
        System.out.println("Tesla----&amp;gt;"+tesla.toString());
        System.out.println("Camry----&amp;gt;"+camry.toString());
    }
}

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here is the full video of the part 2 Base Java Series. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;Subscribe&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/d00Ww1OsT6E"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Beginner Git Essentials</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Sun, 29 Dec 2019 21:05:11 +0000</pubDate>
      <link>https://dev.to/nagarajendra/beginner-git-essentials-11be</link>
      <guid>https://dev.to/nagarajendra/beginner-git-essentials-11be</guid>
      <description>&lt;p&gt;This video is first published on &lt;a href="https://youtu.be/mUT1hax4g7w"&gt;YouTube&lt;/a&gt;&lt;br&gt;
Please &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;subscribe&lt;/a&gt; to my channel for tutorials&lt;br&gt;
In this video, we will be looking into 20 git essential commands.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/mUT1hax4g7w"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>git</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Base Java Part 1</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 23 Dec 2019 13:54:15 +0000</pubDate>
      <link>https://dev.to/nagarajendra/base-java-part-1-41oe</link>
      <guid>https://dev.to/nagarajendra/base-java-part-1-41oe</guid>
      <description>&lt;p&gt;This is a series covering Java basics, which hopefully help a beginner to get up and running.&lt;/p&gt;

&lt;p&gt;In this part1 tutorial, we will cover&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is Java?&lt;/li&gt;
&lt;li&gt;Differences between JDK, JRE, and JVM.&lt;/li&gt;
&lt;li&gt;Features of Java.&lt;/li&gt;
&lt;li&gt;First Java program.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is the full video of the part 1 Base Java Series. Please show some love and subscribe to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1" rel="noopener noreferrer"&gt;HERE&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/p7t4K1EDx-s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Why Java?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Because Java is still among the most popular and most used programming languages because of its scalability and community. It is still the 3rd most language on Github and the 5th most popular language according to StackOverflow 2019 survey.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flfr30elm0k3cifi6urcp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flfr30elm0k3cifi6urcp.png" alt="Github Octoverse"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff20cpsowb7eyrcue5r2n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ff20cpsowb7eyrcue5r2n.png" alt="StackOverflow Survey"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is Java?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Java is a general-purpose programming language that is class-based, object-oriented, and designed to have as few implementation dependencies as possible. It is intended to let application developers write once, run anywhere (WORA), we will get deep into it later.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;History of Java&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Java was developed by sun microsystems, James Gosling is known as the father of Java, The first version of Java JDK (Java Development Kit) was first released in 1995, the latest version at the time of recording is Java SE 13 released September 2019.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Difference between JDK, JRE, JVM&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;JDK (Java Development Kit):&lt;/em&gt;&lt;/strong&gt; JDK is the one you need to build applications in Java, it contains everything that is required to build and run Java applications. When you download java from the oracle site to develop applications you actually download JDK, which comes with JRE and the following Devtools,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;JavaC:&lt;/em&gt;&lt;/strong&gt; Java Compiler which compiles your Java code. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;Java:&lt;/em&gt;&lt;/strong&gt; Interpreter/loader which reads your java code. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;JavaDoc:&lt;/em&gt;&lt;/strong&gt; This helps in generating java documentation for your code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;JRE (Java Runtime Environment):&lt;/em&gt;&lt;/strong&gt; JRE contains everything to run the java application, it contains code libraries required to develop java applications. JRE contains the Java class libraries, the Java class loader, and the Java Virtual Machine. In this system: The class loader is responsible for correctly loading classes and connecting them with the core Java class libraries. The JVM is responsible is to ensure Java applications have the resources they need to run and perform well in your device or cloud environment. The JRE is an orchestrator between these components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;JVM (Java Virtual Machine):&lt;/em&gt;&lt;/strong&gt; JVM is machine-specific and can only read byte code that has been generated using java compiler.  Once the java compiler compiles the code to byte code, JVM is the one which reads it and runs on that machine, you might have heard that Java is portable, this is what it meant the compiled byte code can be run on any machine with the help of JVM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzudx9rtqx1gdzx8umlpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzudx9rtqx1gdzx8umlpf.png" alt="JDK vs JRE vs JVM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might have seen the below image saying Java is being run on 3 billion devices, it actually means JVM is running on 3 billion devices.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fh49azi1o0m2xm4qmrbgq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fh49azi1o0m2xm4qmrbgq.png" alt="Java 3Billion"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Features of Java&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are many features that led Java to be one of the most popular languages for over 2 decades. These are the features of Java.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Forkddw8v4sj1koe4xrve.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Forkddw8v4sj1koe4xrve.png" alt="Java Features"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Object-Oriented&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everything in Java is Object Oriented. We organize our software as a combination of different types of objects that incorporates both data and behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Simple&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java syntax is very simple and easy to learn. The syntax is based on C++ but removed unnecessary and complicated stuff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Platform Independent&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java language is platform-independent, you write once and run anywhere (WORA). When you compile java file with Javac it generates .class file which can run on any machine by installing the JVM on that machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F27qp65gtzyg10ocotomy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F27qp65gtzyg10ocotomy.png" alt="Platform Independent."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Secured&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java is best known for its security, you can build virus free software, it runs inside a virtual machine sandbox, unlike C++ runs on an OS, it doesn't have pointers like C++ which allows it write more secure code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Multi-Threaded&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java multi-threaded features allow the application to run multiple processes concurrently. A process can be divided into multiple threads and can be run on all the threads simultaneously which makes the whole operation faster.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvwi3jtndvlwo0nt5jwx1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fvwi3jtndvlwo0nt5jwx1.png" alt="Java Multi Threaded"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;High Performance&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Java is faster than traditional interpreted languages, as its byte code is closed to the native code. Java uses &lt;strong&gt;&lt;em&gt;JIT (Just in Time)&lt;/em&gt;&lt;/strong&gt; Compilers, which enables for high performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Dynamic&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Supports dynamic loading of classes. Holds excessive amount of run time info, that can be used to access objects during runtime. You don't have to instantiate all the objects at the initialization, you can instantiate the objects when required at the runtime.&lt;/p&gt;

&lt;p&gt;Here is the full video of the part 1 Base Java Series.  Please show some love and &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1" rel="noopener noreferrer"&gt;SUBSCRIBE&lt;/a&gt; to my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1" rel="noopener noreferrer"&gt;HERE&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/p7t4K1EDx-s"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In the next part, we will cover Java Variable, Java Datatypes, Operators and Keywords, etc...&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Persist Data to Firebase With Rest API</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 16 Dec 2019 17:59:21 +0000</pubDate>
      <link>https://dev.to/nagarajendra/persist-data-to-firebase-with-rest-api-217n</link>
      <guid>https://dev.to/nagarajendra/persist-data-to-firebase-with-rest-api-217n</guid>
      <description>&lt;p&gt;In this tutorial will see how to connect to Firebase Firestore Database and persist data using rest web services.&lt;/p&gt;

&lt;p&gt;For this will start from the rest web service that we built using spring boot in the previous blog post &lt;a href="https://dev.to/nagarajendra/build-a-restful-web-service-using-spring-boot-5d2l"&gt;Build Restful web service using Spring boot and Java&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you are a video guy here is the video which demonstrates connecting to Firebase and persists data&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ScsID2yPB8k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Go to firebase.google.com and click on the got to console on the top right corner, it will take you to the console as shown below. Click on Add project and give it a name.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m7YSkdJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k5al5xvg1uxyep4jf1pt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m7YSkdJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/k5al5xvg1uxyep4jf1pt.png" alt="Firebase Console"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once created it will take you to your project console page as shown below, click on the database and create a collection named "users".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NqRvYLjV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rsn7yeafepa78namco6u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NqRvYLjV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rsn7yeafepa78namco6u.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GNtKMAaC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rbejc9hk677cywcdrnfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GNtKMAaC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/rbejc9hk677cywcdrnfq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once created the collection, we will go to &lt;strong&gt;&lt;em&gt;project settings -&amp;gt; service Accounts&lt;/em&gt;&lt;/strong&gt; tab to generate the key and save it in your project, that we will use to connect to the firebase firestore database. We will also grab the admin SDK configuration snippet for java.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l4J8_wcf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pgg4prjd4tvzi5dy3lbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l4J8_wcf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/pgg4prjd4tvzi5dy3lbe.png" alt="Firebase Console Service Accounts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now open the pom.xml and add the google firebase admin SDK dependency&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;com.google.firebase&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;firebase-admin&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;6.11.0&amp;lt;/version&amp;gt;
 &amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Add a file named FirebaseInitialize which we will use to make a connection to firebase during the application startup. The class looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo.service;

import java.io.FileInputStream;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Service;
import com.google.auth.oauth2.GoogleCredentials;

import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;

@Service
public class FirebaseInitialize {

    @PostConstruct
    public void initialize() {
        try {
        FileInputStream serviceAccount =
                  new FileInputStream("./serviceAccount.json");

                FirebaseOptions options = new FirebaseOptions.Builder()
                  .setCredentials(GoogleCredentials.fromStream(serviceAccount))
                  .setDatabaseUrl("https://fir-demo-8920f.firebaseio.com")
                  .build();

                FirebaseApp.initializeApp(options);
    } catch (Exception e) {
        e.printStackTrace();
    }

}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;@Service&lt;/em&gt;&lt;/strong&gt; Annotation lets the spring bootup know that it is a service class and needs to be bound.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;@PostConstruct&lt;/em&gt;&lt;/strong&gt; Annotation specifies that the function &lt;strong&gt;&lt;em&gt;initialize()&lt;/em&gt;&lt;/strong&gt; should run before the launch of the application, so it creates a firebase connection.&lt;br&gt;
We have the code that we copied from the firebase console in the earlier step pasted here.&lt;br&gt;
The first line reads the &lt;strong&gt;&lt;em&gt;serviceAccount.json&lt;/em&gt;&lt;/strong&gt; which we generated on the firebase project settings page from step 1.&lt;br&gt;
It connects to firebase with &lt;strong&gt;&lt;em&gt;FirebaseApp.initializeApp&lt;/em&gt;&lt;/strong&gt; using the options build using &lt;strong&gt;&lt;em&gt;FirebaseOptionsBuilder&lt;/em&gt;&lt;/strong&gt; which will have credentials that we extracted from &lt;strong&gt;&lt;em&gt;serviceAccount.json&lt;/em&gt;&lt;/strong&gt; and the databaseURL.&lt;/p&gt;

&lt;p&gt;We will now write a Firebase Service class which will have four functions to do crud operations, &lt;strong&gt;&lt;em&gt;createUser (to create new User)&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;updateUser (to update existing User)&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;getUserDetails(to retrieve user details)&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;deleteUser (to delete existing User)&lt;/em&gt;&lt;/strong&gt; the class looks like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo.service;

import java.util.concurrent.ExecutionException;

import org.springframework.stereotype.Service;

import com.example.demo.objects.Person;
import com.google.api.core.ApiFuture;
import com.google.cloud.firestore.DocumentReference;
import com.google.cloud.firestore.DocumentSnapshot;
import com.google.cloud.firestore.Firestore;
import com.google.cloud.firestore.WriteResult;
import com.google.firebase.cloud.FirestoreClient;

@Service
public class FirebaseService {

    public String saveUserDetails(Person person) throws InterruptedException, ExecutionException {
        Firestore dbFirestore = FirestoreClient.getFirestore();
        ApiFuture&amp;lt;WriteResult&amp;gt; collectionsApiFuture = dbFirestore.collection("users").document(person.getName()).set(person);
        return collectionsApiFuture.get().getUpdateTime().toString();
    }

    public Person getUserDetails(String name) throws InterruptedException, ExecutionException {
        Firestore dbFirestore = FirestoreClient.getFirestore();
        DocumentReference documentReference = dbFirestore.collection("users").document(name);
        ApiFuture&amp;lt;DocumentSnapshot&amp;gt; future = documentReference.get();

        DocumentSnapshot document = future.get();

        Person person = null;

        if(document.exists()) {
            person = document.toObject(Person.class);
            return person;
        }else {
            return null;
        }
    }

    public String updateUserDetails(Person person) throws InterruptedException, ExecutionException {
        Firestore dbFirestore = FirestoreClient.getFirestore();
        ApiFuture&amp;lt;WriteResult&amp;gt; collectionsApiFuture = dbFirestore.collection("users").document(person.getName()).set(person);
        return collectionsApiFuture.get().getUpdateTime().toString();
    }

    public String deleteUser(String name) {
        Firestore dbFirestore = FirestoreClient.getFirestore();
        ApiFuture&amp;lt;WriteResult&amp;gt; writeResult = dbFirestore.collection("users").document(name).delete();
        return "Document with ID "+name+" has been deleted";
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We will have this class also defined with &lt;strong&gt;&lt;em&gt;@Service&lt;/em&gt;&lt;/strong&gt; annotation so it will be available for auto wiring.&lt;br&gt;
Since having the connection to the database initialized earlier we will extract the DB here to perform operations on that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Firestore dbFirestore = FirestoreClient.getFirestore();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;this will instantiate the firestore client object which we will use to access the collections we created.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ApiFuture collectionsApiFuture = dbFirestore.collection("users").document(person.getName()).set(person)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;this line of syntax gets the collection "users" and tries to document with id (In our case I'm setting the id as the user's name) if it didn't find the document with specified id it will create the new document with Person object.&lt;br&gt;
If there is an id already exists it will update the document, if you observer the function updateUser it will have the same logic as createUser.&lt;br&gt;
For &lt;strong&gt;&lt;em&gt;deleteUser&lt;/em&gt;&lt;/strong&gt; the syntax would be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dbFirestore.collection("users").document(person.getName())
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you have a problem following the tutorial, here is the video which demonstrates the complete tutorial.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/ScsID2yPB8k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>beginners</category>
      <category>java</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Build A RESTful Web Service Using Spring Boot</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Thu, 12 Dec 2019 06:07:08 +0000</pubDate>
      <link>https://dev.to/nagarajendra/build-a-restful-web-service-using-spring-boot-5d2l</link>
      <guid>https://dev.to/nagarajendra/build-a-restful-web-service-using-spring-boot-5d2l</guid>
      <description>&lt;p&gt;The continuation of this tutorial is here &lt;a href="https://dev.to/nagarajendra/connect-to-firebase-and-persist-data-with-rest-api-2acc"&gt;connect to firebase and persist data&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this following tutorial, we will build a simple REST web service using java with spring boot.&lt;/p&gt;

&lt;p&gt;Here is the complete video if you like to watch the video instead.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9_miu0ihe1k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;What is a Web Service?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Web Service is a standard or common way of communication between a client and a server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V1uEf5tP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kimdm4or64dfj6s21m1o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V1uEf5tP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/kimdm4or64dfj6s21m1o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above diagram shows the pictorial representation of a web service call, the clients a computer, or a phone are basically clients, when you try to perform open facebook app your mobile phone app, it sends a web service request (Http Request) to get the data to show on your feed.&lt;/p&gt;

&lt;p&gt;There are in general two kinds of web services in usage&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;SOAP&lt;/em&gt;&lt;/strong&gt; (Simple Object Access Protocol).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;REST&lt;/em&gt;&lt;/strong&gt; (REpresentational State Transfer).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;SOAP:&lt;/em&gt;&lt;/strong&gt; SOAP as the name says it's an access protocol to make requests and receive responses based on a protocol that will be defined between the client and the server.&lt;br&gt;
There are many caveats of using SOAP one of it is you can only transfer and receive XML data when using a SOAP web service. Hence restful web services came into existence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;REST:&lt;/em&gt;&lt;/strong&gt; Rest as the name says its a state of transferring data between clients and servers, there are no set protocols attached to it, you can send any kind of data, XML, JSON, TEXT, FILE format data using REST web services, in most cases, you will be using JSON format.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;SPRING BOOT&lt;/em&gt;&lt;/strong&gt; makes it so much easier to build REST web services from the ground up, it provides a lot of configuration inbuilt so that you can build web services/ microservices rapidly, it also provides inbuilt tomcat server which removes the hassle of having a server install in and deploy your JAR/WAR file like the old times,  we will see how to build the rest web service using Spring boot, Java and maven build tool.&lt;/p&gt;

&lt;p&gt;Using the spring tool suite we can create a sample spring boot project.  Go to &lt;strong&gt;&lt;em&gt;File -&amp;gt; New -&amp;gt; Other Project&lt;/em&gt;&lt;/strong&gt; and select &lt;strong&gt;&lt;em&gt;Spring boot-&amp;gt; Spring boot Starter project&lt;/em&gt;&lt;/strong&gt; it will create you a default spring boot project.&lt;/p&gt;

&lt;p&gt;Follow the steps on STS/eclipse and you will have your demo application created and you should be able to see a java file named DemoApplication.java (Demo is the name of the project) which will look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package com.example.demo;&lt;br&gt;
import org.springframework.boot.SpringApplication;&lt;br&gt;
import org.springframework.boot.autoconfigure.SpringBootApplication;&lt;br&gt;
@SpringBootApplication&lt;br&gt;
public class DemoApplication {&lt;br&gt;
    public static void main(String[] args) {&lt;br&gt;
        SpringApplication.run(DemoApplication.class, args);&lt;br&gt;
    }&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;@SpringBootApplication&lt;/em&gt;&lt;/strong&gt; annotation takes care of three annotations combined&lt;br&gt;
        &lt;strong&gt;&lt;em&gt;@Configuration:&lt;/em&gt;&lt;/strong&gt; Tags the class as a source of bean definitions for the application context.&lt;br&gt;
        &lt;strong&gt;&lt;em&gt;@EnableAutoConfiguration:&lt;/em&gt;&lt;/strong&gt;  Tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if spring-webmvc is on the classpath, this annotation flags the application as a web application.&lt;br&gt;
       &lt;strong&gt;&lt;em&gt;@ComponentScan:&lt;/em&gt;&lt;/strong&gt;  Tells Spring to look for other components, configurations, and services in the base package in our case com.example.demo letting it find the controllers.&lt;/p&gt;

&lt;p&gt;If you have never used Spring MVC you might have not known of these annotations. Spring boot starter project also creates a POM.XML like below which will have all the required dependencies except &lt;strong&gt;&lt;em&gt;spring-boot-starter-web&lt;/em&gt;&lt;/strong&gt; dependency which we need to add for creating Rest web service.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;
&amp;lt;project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0https://maven.apache.org/xsd/maven-4.0.0.xsd"&amp;gt;&lt;br&gt;
    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;&lt;br&gt;
    &amp;lt;parent&amp;gt;&lt;br&gt;
        &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&lt;br&gt;
        &amp;lt;artifactId&amp;gt;spring-boot-starter-parent&amp;lt;/artifactId&amp;gt;&lt;br&gt;
        &amp;lt;version&amp;gt;2.2.2.RELEASE&amp;lt;/version&amp;gt;&lt;br&gt;
        &amp;lt;relativePath/&amp;gt; &amp;lt;!-- lookup parent from repository --&amp;gt;&lt;br&gt;
    &amp;lt;/parent&amp;gt;&lt;br&gt;
    &amp;lt;groupId&amp;gt;com.example&amp;lt;/groupId&amp;gt;&lt;br&gt;
    &amp;lt;artifactId&amp;gt;demo&amp;lt;/artifactId&amp;gt;&lt;br&gt;
    &amp;lt;version&amp;gt;0.0.1-SNAPSHOT&amp;lt;/version&amp;gt;&lt;br&gt;
    &amp;lt;name&amp;gt;demo&amp;lt;/name&amp;gt;&lt;br&gt;
    &amp;lt;description&amp;gt;Demo project for Spring Boot&amp;lt;/description&amp;gt;&lt;br&gt;
    &amp;lt;properties&amp;gt;&lt;br&gt;
        &amp;lt;java.version&amp;gt;1.8&amp;lt;/java.version&amp;gt;&lt;br&gt;
    &amp;lt;/properties&amp;gt;&lt;br&gt;
    &amp;lt;dependencies&amp;gt;&lt;br&gt;
        &amp;lt;dependency&amp;gt;&lt;br&gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&lt;br&gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;&lt;br&gt;
        &amp;lt;/dependency&amp;gt;   &lt;br&gt;
        &amp;lt;dependency&amp;gt;&lt;br&gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&lt;br&gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter&amp;lt;/artifactId&amp;gt;&lt;br&gt;
        &amp;lt;/dependency&amp;gt;&lt;br&gt;
        &amp;lt;dependency&amp;gt;&lt;br&gt;
            &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&lt;br&gt;
            &amp;lt;artifactId&amp;gt;spring-boot-starter-test&amp;lt;/artifactId&amp;gt;&lt;br&gt;
            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br&gt;
            &amp;lt;exclusions&amp;gt;&lt;br&gt;
                &amp;lt;exclusion&amp;gt;                 &amp;lt;groupId&amp;gt;org.junit.vintage&amp;lt;/groupId&amp;gt;&lt;br&gt;
            &amp;lt;artifactId&amp;gt;junit-vintage-engine&amp;lt;/artifactId&amp;gt;&lt;br&gt;
                &amp;lt;/exclusion&amp;gt;&lt;br&gt;
            &amp;lt;/exclusions&amp;gt;&lt;br&gt;
        &amp;lt;/dependency&amp;gt;&lt;br&gt;
    &amp;lt;/dependencies&amp;gt;&lt;br&gt;
    &amp;lt;build&amp;gt;&lt;br&gt;
        &amp;lt;plugins&amp;gt;&lt;br&gt;
            &amp;lt;plugin&amp;gt;                &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;&lt;br&gt;
                &amp;lt;artifactId&amp;gt;spring-boot-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;br&gt;
            &amp;lt;/plugin&amp;gt;&lt;br&gt;
        &amp;lt;/plugins&amp;gt;&lt;br&gt;
    &amp;lt;/build&amp;gt;&lt;br&gt;
&amp;lt;/project&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Now we will go ahead and create a controller class that will have our REST endpoints, which will look something like below.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package com.example.demo.controller;&lt;br&gt;
import org.springframework.web.bind.annotation.DeleteMapping;&lt;br&gt;
import org.springframework.web.bind.annotation.GetMapping;&lt;br&gt;
import org.springframework.web.bind.annotation.PostMapping;&lt;br&gt;
import org.springframework.web.bind.annotation.PutMapping;&lt;br&gt;
import org.springframework.web.bind.annotation.RequestBody;&lt;br&gt;
import org.springframework.web.bind.annotation.RequestHeader;&lt;br&gt;
import org.springframework.web.bind.annotation.RestController;&lt;br&gt;
import com.example.demo.object.Person;&lt;br&gt;
@RestController&lt;br&gt;
public class UserController {   &lt;br&gt;
    @GetMapping("/getUserDetails")&lt;br&gt;
    public String getUserDetails(@RequestHeader String name) {&lt;br&gt;
        return "Requesting Details of User"+name;&lt;br&gt;
    }   &lt;br&gt;
    @PostMapping("/createUser")&lt;br&gt;
    public String createNewUser(@RequestBody Person person) {&lt;br&gt;
        return "Created new User "+person.getName();&lt;br&gt;
    }   &lt;br&gt;
    @PutMapping("/updateUser")&lt;br&gt;
    public String updateUser(@RequestBody Person person) {&lt;br&gt;
        return "Updated user "+person.getName();&lt;br&gt;
    }   &lt;br&gt;
    @DeleteMapping("/deleteUser")&lt;br&gt;
    public String deleteUser(@RequestBody Person person) {&lt;br&gt;
        return "Deleted User "+person.getName();&lt;br&gt;
    }&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;HTTP Methods:&lt;/em&gt;&lt;/strong&gt; There are four main HTTP methods that we use in common for web service calls they are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;GET&lt;/em&gt;&lt;/strong&gt; (used to retrieve existing data).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;POST&lt;/em&gt;&lt;/strong&gt; (used to create/insert new data).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;PUT&lt;/em&gt;&lt;/strong&gt; (used to update existing data).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;em&gt;DELETE&lt;/em&gt;&lt;/strong&gt; (used to delete data).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We have implemented all these methods in the above UserController class. &lt;br&gt;
&lt;strong&gt;&lt;em&gt;@RestController&lt;/em&gt;&lt;/strong&gt; lets the spring boot application that this class is a controller class having rest endpoints so that spring configures this class to its HTTP routes.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;@GetMapping&lt;/em&gt;&lt;/strong&gt;, having this annotation makes the corresponding method is called when a get call is made to the endpoint /getUserDetails.&lt;br&gt;
Similarly &lt;strong&gt;&lt;em&gt;@PostMapping&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;@PutMapping&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;@DeleteMapping&lt;/em&gt;&lt;/strong&gt; calls the corresponding methods/functions when those methods are used.&lt;br&gt;
&lt;strong&gt;&lt;em&gt;@RequestHeader&lt;/em&gt;&lt;/strong&gt; captures the data sent in the header parameters and &lt;strong&gt;&lt;em&gt;@RequestBody&lt;/em&gt;&lt;/strong&gt; captures the data sent in the body of the Rest Call.&lt;/p&gt;

&lt;p&gt;That is all you need to bring up the service, set up the run configurations in STS or whichever IDE you might be using pointing to the DemoApplication.java class as the main class, it boots up the spring application using inbuilt tomcat and your services will be available on PORT &lt;strong&gt;&lt;em&gt;8080&lt;/em&gt;&lt;/strong&gt; by default.&lt;/p&gt;

&lt;p&gt;You can follow through this video if you need any help in getting it up and running&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/9_miu0ihe1k"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The continuation of this tutorial is here &lt;a href="https://dev.to/nagarajendra/connect-to-firebase-and-persist-data-with-rest-api-2acc"&gt;connect to firebase and persist data&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>java</category>
      <category>spring</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What it takes to make your first YOUTUBE video?</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Mon, 09 Dec 2019 17:41:30 +0000</pubDate>
      <link>https://dev.to/nagarajendra/what-it-takes-to-make-your-first-youtube-video-5d70</link>
      <guid>https://dev.to/nagarajendra/what-it-takes-to-make-your-first-youtube-video-5d70</guid>
      <description>&lt;p&gt;I have been procrastinating to make a youtube video for so long, it took me about 30 hours since I firmly decided to make a video.&lt;/p&gt;

&lt;p&gt;The desire to make a tutorial video started long back when I was unable to understand many tutorials on youtube and other sites. The issue is not that the videos are good enough, the issue is the teaching style didn't work for me.&lt;/p&gt;

&lt;p&gt;Finally, I decided to make a video about 2 months ago, I want my first video should be simple and useful to the #webdev community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 (Deciding on a topic)&lt;/strong&gt;: Again procrastinating comes into play, I spent a lot of time thinking on the topic HTML? CSS? JAVASCRIPT? JAVA? finally, I ended up picking &lt;a href="https://www.youtube.com/watch?v=kP7rc2shTA8&amp;amp;t=1s"&gt;How to make VS CODE User Snippets&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Please &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;CLICK HERE&lt;/a&gt; if you like to subscribe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 (Tools)&lt;/strong&gt;: As a beginner, we strive for perfection and quality, so I started trying a bunch of screen recording tools, microphones, audio mixers, etc.. and if I have to buy the best products in the market I would definitely go bankrupt. so I decided to use &lt;strong&gt;Camtasia 2&lt;/strong&gt; for screen recording and editing which I bought years ago on the app store with a gift card I got from apple,(Imovie and Quick time are free tools you can use if you have MAC). I wanted a decent microphone as audio plays a major role, so I bought the Blue Yeti USB microphone during thanksgiving deals.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Camtasia 2(Video/Screen Recording and Editing).&lt;/li&gt;
&lt;li&gt;Blue Yeti Microphone (For good voice quality).&lt;/li&gt;
&lt;li&gt;Canva (To create thumbnail and title animation).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Free Tool Alternative:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;QUICK TIME &amp;amp; IMovie For MAC, CamStudio for windows.&lt;/li&gt;
&lt;li&gt;Use the inbuilt MAC/PC microphone or your Earpiece microphone.&lt;/li&gt;
&lt;li&gt;Canva (It's free for creating thumbnails or simple stuff, there is a paid plan as well)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Step 3 (Recording &amp;amp; Editing)&lt;/strong&gt;: Its recording time, it felt very weird hearing my voice recorded, I spent almost 2 hours for a 10 minute video re-recording what I recorded the first time, surprise it didn't get any better than the first time and I got really tired. Final step editing, since me being a newbie in editing it took me 2 hours to edit the video and get it down to some 8 minutes, I wanted the video to be crisp so I edited a lot of gaps and fillers.&lt;/p&gt;

&lt;p&gt;Finally, I uploaded the video on youtube and got a huge number of views, just kidding I got 10 views all mostly from my friends whom I asked to watch.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/kP7rc2shTA8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;The bottom line is just don't wait to be perfect in anything, just started doing even though it sucks like my &lt;a href="https://www.youtube.com/watch?v=kP7rc2shTA8&amp;amp;t=1s"&gt;VIDEO&lt;/a&gt; on youtube. I will try to make more tutorials and fun videos on my channel &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ"&gt;HackerHeap&lt;/a&gt;. Please &lt;a href="https://www.youtube.com/channel/UCBRX8VfhAp7FJ_13uzpI_pQ?sub_confirmation=1"&gt;CLICK HERE&lt;/a&gt; if you like to subscribe.&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>Hi, I'm NagaRajendra.Chamata</title>
      <dc:creator>Rajendra🙏🏼👇🏽</dc:creator>
      <pubDate>Thu, 01 Jun 2017 16:54:28 +0000</pubDate>
      <link>https://dev.to/nagarajendra/hi-im-nagarajendrachamata</link>
      <guid>https://dev.to/nagarajendra/hi-im-nagarajendrachamata</guid>
      <description>&lt;p&gt;I have been coding for 6 years.&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/rajendrach" rel="noopener noreferrer"&gt;rajendrach&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Chicago Metro Area.&lt;/p&gt;

&lt;p&gt;I work for Capital One&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: Java, Java Script(NodeJS, AngularJS, ReactJS), Python(Novice).&lt;/p&gt;

&lt;p&gt;I am currently learning more about Machine Learning/Deep Learning/AI.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
