Posts

Showing posts from February, 2021

Creating a Hello World Spring Boot Application in Eclipse Using Maven

Image
In this blog post, I will be explaining how you can create a Hello World Spring Boot application in Eclipse using Maven. Edit What is Spring Boot? Spring boot sits on top of Spring. It automatically does the configuration of the application for you by assuming some defaults. These defaults are sufficient to get you started most of the times but you easily change these default values if required. This allows you to have a spring application up and running very quickly without having to bother with boiler plate stuff. All you have to do is tell Spring boot the type of application you are building. It provides Embedded HTTP servers like Tomcat , Jetty etc. which makes it easy to develop web applications. In order to know more about Spring Boot, you can refer to this blog post. Creating Hello World Spring Boot Application Let us now learn how to create a basic Hello World Spring Boot application in Eclipse using Maven Project Creating and setup Step 1 – Create a new Maven Proje

DoubleUnaryOperator in Java 8 With Code Sample

In this blog post, I will be explaining how the Java 8 functional interface  DoubleUnaryOperator works. To know more about functional interfaces, you can refer to this  blog post. Edit What is DoubleUnaryOperator DoubleUnaryOperator is an in-built functional interface in the java.util.Function package. It accepts an argument of double data type, operates on it and produces a result of type double . It is a specialization of the UnaryOperator interface. It has an applyAsDouble method. It applies the logic in this method on the double argument passed in and produces a double result. DoubleUnaryOperator Code Sample The following code demonstrates this   interface: DoubleUnaryOperator doubleUnaryOp = num -> Math.sqrt(num);double input = 9;double result = doubleUnaryOp.applyAsDouble(input);System.out.println("result:"+result); Line 1 declares a DoubleUnaryOperator instance doubleUnaryOp and implements it via a lambda expression that returns the square root of the in

JPA Interfaces explained with code samples

In my earlier article, we had learnt how to create a basic JPA application.  In this article, I will be explaining the important JPA interfaces. Persistence Unit As seen earlier , we need to create a configuration file called persistence.xml that contains the database configuration details as follows: <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1"> <persistence-unit name="PERSISTENCE"> <description>JPA Demo</description> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>