Skip to main content

Posts

Showing posts from April, 2022

Spring Boot RestTemplate Guide with Example

What is RestTemplet? RestTemplate is a HTTP Client library that provides basic APIs for executing different HTTP type requests. RestTemplate is one of the HTTP libraries available on the market. The Spring Boot team designed and maintains it. As previously said, it is a client library, which means it may be utilised in our application as a stand-alone dependency. To utilise it, you don't require a complete Spring boot application. It's suitable for use in simple Java applications as well as other frameworks such as Micronaut, Play and others. Setup Add RestTemplate dependency to project, for this tutorial I am creating a simple java application to consume HTTP request and a node application to provide HTTP service. For Gradle build tool Add the following dependency in the build.gradle file . // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web implementation group: 'org.springframework.boot' , name: 'spring-boot-starter-w

How to Change a Git Commit Message?

In this tutorial, we'll go over how to fix Git commit messages that have been committed to a local or remote Git repository. Reason to change commit message? When working with Git, there could be several reasons to update the commit message. Some of the common reasons are as follows: Message contains a typo. Missing intent of commit. Remove any confidential information. Correct issue ticket number to connect to an issue tracker such as Jira. Solution The reason could be anything, but you should be aware of the command to update the commit message at any point in the development of your application. Let's take a look at the solution for a single commit message. local commit Assume you perform the following Git operation $ git add -A $ git commit -m "[PROJECT-99] - Added user profile module." And after you realise that the issue number for the current commit is incorrect and needs to be corrected. That's the story of Project 100. You can correct it

How to enable SQL logs in Spring Boot application?

This tutorial will demonstrate how to enable and disable SQL log statements in a Spring Boot application in order to debug SQL flow. Problem You will frequently need to debug the SQL statement while developing a Spring Boot application with a SQL database. SQL debug logs can assist you figure out what's wrong with JPA statements and whether or not there's a problem with database connectivity. Example  If you've built custom Spring data JPA methods and need to know what SQL statement is being utilized behind them, return repository . findByUsernameIn ( usernames ); Then you can enable Hibernet debug mode to log SQL statements. Solution Update the application.yml file with the Hibernet configuration as logging: level: org: hibernate: DEBUG or application.properties as logging.level.org.hibernate=DEBUG The SQL statement will appear in the application logs after modifying the configuration file and restarting the application. 2022-04-07 08:41

Cucumber setup using Gradle

This tutorial will help you configure Cucumber into a Java project using the Gradle build tool. Introduction Cucumber is a test automation tool that supports Behavior-Driven Development (BDD).  It is written in plain English text called "Gherkin." Cucumber enables you to write test cases that anyone can easily understand, regardless of their technical knowledge. Setup First, create a Gradle project using the gradle init command. > gradle init Complete the Gradle wizard to create a project. Now update the gradle.build file to add the Gradle Cucumber dependency. testImplementation 'io.cucumber:cucumber-java8:7.0.0' This will add Cucumber implementation to your project. Task Configuration Add the following configuration to gradle.build This will enable the Cucumber runtime to execute BDD test cases. configurations { cucumberRuntime { extendsFrom testImplementation } } Create a new custom task to execute Cucumber  task cucumber ()

Subscribe for latest tutorial updates

* indicates required