Building a RESTful Web Service in Spring Boot

Starting with Spring Initializr

plugins {
id 'org.springframework.boot' version '2.4.2'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}

group = 'net.codinghub'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test')
}

test {
useJUnitPlatform()
}

Create a Resource Representation Class

{ 
"id": 1,
"content": "Coding Hub"
}

Create a Resource Controller

Build an executable JAR

java -jar target/rest-service-0.0.1-SNAPSHOT.jar
java -jar build/libs/rest-service-0.0.1-SNAPSHOT.jar

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
CodingHub

CodingHub

Coding Hub — Learn & Build Your Career