Posts

Showing posts with the label SpringBoot

How to create Spring Boot REST Service and Test it via Postman

Image
In this blog post, I will be explaining how you can create a Spring Boot REST service.  If you would like to see how to create a basic HelloWorld Spring Boot application refer to this blog post. Edit Project Creation and Setup Step 1 – Create a new Maven Project (Refer to this blog post)   Step 2 – Add the following Spring Boot dependencies to the POM file and save. <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.2.RELEASE</version></parent><dependencies><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency></dependencies> Edit Writing Code Step 3 – Create Person class as follows package com.learnjava.model;public class Person { private int id; private String name; private int age; public int getId()...

Spring Boot JPA Example with Eclipse and Maven

Image
In this blog post, I will be demonstrating how you can insert records and query a database table via Spring Boot and JPA using Eclipse and Maven Edit Step 1 – Create a New Maven Project Create a new Maven project. (Refer to this blog post). This will create a project in Eclipse as follows: Step 2 – Add Spring Boot JPA dependencies to the pom file Add the following text to the pom.xml file: <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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.learnjava</groupId> <artifactId>SpringBootJPADemo</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> ...