Spring Boot-Series Part 2: What is pom.xml in a maven based Spring Project?

The full form of POM is Project Object Model. It is a fundamental unit of work in Maven. pom is a XML file that contains information about the project and configuration details used by Maven to build the project.

Mockito 101 – Unit Testing in Java Apps

Mockito is an open source framework that allows you to easily create mocks (test doubles). Mocks are objects that have return values to method executions made during the test and has recorded expectations of these executions. Mocks can also throw an exception if they receive a call they don’t expect. They are checked during verification to ensure … Continue reading Mockito 101 – Unit Testing in Java Apps

Tomcat Started in Eclipse but showing Connection refused in browser – Error Solved!

I recently was building an old application in eclipse and came across a hurdle while publishing my Spring MVC based java application on tomcat server. The error was nothing! That strange beacause tomcat was started in eclipse and in console it was showing server startup status. But when I hit localhost:8080 in my browser the … Continue reading Tomcat Started in Eclipse but showing Connection refused in browser – Error Solved!

Dynamic String Conversion in JAVA

Input: 2B Output: 2000000000 Code : import java.math.BigDecimal; import java.util.Scanner; public class DyanamicConversion { public static void main(String args[]){ //Scanner scan = new Scanner(System.in); String a ="2M"; String[][] conversion = {{"K","1000"},{"M","1000000"},{"B","1000000000"}}; for(int i=0;i<conversion.length;i++){ if(a.endsWith(conversion[i][0])){ BigDecimal temp = new BigDecimal(a.substring(0, a.indexOf(conversion[i][0]))); temp.multiply(new BigDecimal(conversion[i][1])); a = temp.toBigInteger().toString(); System.out.println(a); break; } } } }

Sending HTTP GET Request to a REST API in JAVA

HTTP/HTTPS Get/Post request /response using JAVA below. For detailed visit here: https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/ Code: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class HttpURLConnection { public static void main(String[] args) throws IOException { String response = httpGet("https://services.groupkt.com/state/get/IND/all"); } public static String httpGet(String urlStr) throws IOException { URL obj = new URL(urlStr); HttpsURLConnection con … Continue reading Sending HTTP GET Request to a REST API in JAVA