Posts

Showing posts with the label Java 17

Java, Helidon SE get URL query string parameters example

Image
Hello everyone, Today, we will show you how to create a simple REST API with  Helidon SE 2.5.0  and  Java 17  and how to get URL  query string parameters. Quick Overview: Helidon SE is designed to be a microframework that fortifies the reactive programming model. Helidon SE features three core APIs to engender a microservice -- a web server, configuration, and security -- for building microservices-predicated applications.  Helidon's web server is an asynchronous and reactive API that runs on top of Netty. The  WebServer  interface includes support for configuration, routing, error handling, and building metrics and health endpoints. The  Config  loads and processes configuration properties(application.properties or application.yaml) in key/value format.  The  Security  class provides support for authentication, sanction, and audit. Query parameters are a defined set of parameters affixed to the end of a url. They are extensions of the URL that are used to avail define specific con

How to Create a REST API With Helidon SE and Java?

Image
Hello everyone, Today, we will show you how to create a simple REST API with Helidon SE 2.5.0 and Java 17 . Quick Overview: Helidon SE is designed to be a microframework that fortifies the reactive programming model. Helidon SE features three core APIs to engender a microservice -- a web server, configuration, and security -- for building microservices-predicated applications.  Helidon's web server is an asynchronous and reactive API that runs on top of Netty. The WebServer interface includes support for configuration, routing, error handling, and building metrics and health endpoints. The Config loads and processes configuration properties(application.properties or application.yaml) in key/value format.  The Security class provides support for authentication, sanction, and audit. Let's begin, Final Project Directory: Maven [pom.xml]: <?xml version = "1.0" encoding = "UTF-8" ?> <project xmlns = "http://maven.apache.org/POM/4.0.0" x

Unit testing Java HttpClient with MockWebServer from OkHttp

Image
Hello everyone, here you will learn unit testing Java HttpClient with MockWebServer from OkHttp. The  Source code download link is provided at the end of this tutorial. The HTTP Client was added in Java 11 onwards. It can be used to request HTTP resources over the network. It fortifies HTTP/1.1 and HTTP/2, both synchronous and asynchronous programming models, handles request and replication bodies as reactive-streams, and follows the familiar builder pattern. MockWebServer makes it possible to facilely test how our apps comport when making HTTP/HTTPS calls. A mock web server is a program that mocks the behaviour of an actual remote server but doesn't make calls over the internet world. Technologies Used: Java 17 OkHttp MockWebServer Maven 3+ jackson databinder Final project directory: Okhttp mockwebserver and jackson databinder dependencies <properties> <maven.compiler.target> 17 </maven.compiler.target> <maven.compiler.source> 17 </ma

Java Record as DTO in Spring Boot Application

Image
In this section, we will show how we used Java Record as DTO in the Spring Boot application. The  GitHub repository link is provided at the end of this tutorial. You can download the source code. From Java 14 onwards, the record is a special type of class declaration aimed at reducing the boilerplate code. Technologies used :  Spring Boot 2.6.3 Spring  Data JPA  Java 17  H2 DB Maven 3+  Let's do it, Final Project Directory Maven[pom.xml]   A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details utilized by Maven to build the project.  <?xml version = "1.0" encoding = "UTF-8" ?> <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" > <modelVersion&g