Posts

Showing posts with the label JAVA

Setting up Lombok with SpringToolSuite and Intellij Idea

Image
Lombok is a java library that you can plug into your editor which will automatically generate code in .class file instead of in source file. E.g:   getters, setters toString, equals, hashcode, builder, loggers, and many others. In this tutorial, I’ll talk about configuring it in two of the most popular IDEs- IntelliJ IDEA and Spring Tool Suite. Check my Github repo to learn project Lombok using java source code. Note: Step for installing the plugin for Eclipse and Spring tool Suite (STS) are the same. Steps to configure Lombok in STS Download Lombok jar from the Lombok site. Double click on Lombok jar which will open below Installer wizard, Choose IDEs in which you want to install. If your not IDE is not listed then you can browse using Specify location tab. Once selected, click on Install/update button and you are done. Steps to configure Lombok in IntelliJ IDEA Open IntelliJ Idea and click on File-> Settings… Click on Plugin opt...

SonarQube setup on windows 10

Image
Overview SonarQube is an automatic code review tool to detect bugs, vulnerabilities and code smell in your code. It can integrate with your existing workflow to enable continuous code inspection across your project branches and pull requests.  Prerequisite Make sure you have JAVA 11 or higher version installed on your window machine. Step to setup SonarQube Download Community edition from https://www.sonarqube.org/downloads/ Extract it and go to the bin folder. Choose windows-x86–32 or windows-x86–64 based on your machine configuration. Run StartSonar.bat which will start the SonarQube server.  Open browser and hit http://localhost:9000 If you want, you can start the sonarQube server to a different port by just updating the port number (sonar.web.port=9070) to sonar.properties which is present under conf directory. You can login to the portal using default credential (admin:admin). Congratulation! SonarQube server is up and running on loca...

Microservices: Service Registry and Discovery

Image
In my previous blog, I have already talked about Netflix Hystrix Circuit Breaker Microservices and explained it by creating two applications i.e. Product Service and Price Service. In this post, I’ll use both applications to explain what is the Service Registry and Discovery Server. Circuit Breaker and Microservices Architecture Netflix Hystrix Circuit Breaker   What is Service Registry and Discovery and why do we need it in the first place? In our monolithic application, mostly service invoke one another through language methods or procedure calls and even in traditional distributed system deployment, services run at fixed, well-known locations (hosts and ports) and so can easily call one another using HTTP/REST. Over here the network locations of service instances are relatively static. With the microservice architecture system, this is a much more difficult problem as service instances have dynamically assigned network locations. Service instances change dynamicall...

JAVA 11 – New String methods

JAVA 11 – New String methods In this blog, we will discuss about all six new methods which got introduced with JDK 11. isBlank(): returns true if string is empty otherwise false. White spaces code will also be considered as empty string. // Java 8 Predefine Functional Interface              // The best way to learn JAVA 8 is to implement it wherever you can...              BiConsumer<String, String> display = ( msg1 , msg2 ) -> System. out .println( msg1 + msg2 );              // local variable type inference              var msg = "Welcome to waheedtechblog page" ;              // String msg = "Welcome to waheedtechblog page"; both are same ...

Java 10 - Local Variable Type Inference

Java 10 - Local Variable Type Inference In one of my previous blog, I have already discussed about Type Inference. If you don’t have the idea about Type Inference then you can check my blog here . If we want to understand Type Inference in one line then we can say that It is the capability of the compiler to automatically detect the datatype of a variable at the compiler time. What is Local Variable type inference? Java 10 added new feature that allows the developer to skip the type declaration associated with local variables (those defined inside method definitions, initialization blocks, for-loops, and other blocks like if-else), and the type is inferred by the JDK. It will, then, be the job of the compiler to figure out the datatype of the variable. Until Java 9 , we had to define the type of the local variable. E.g.: String message = “Welcome to Waheedtechblog.com”; The above statement is right as that’s how things have been since the inception of java b...