Skip to content

vedab/spring-boot-quickstart

Repository files navigation

Spring Boot quickstart application

Build Status Bitdeli Badge

Purpose

Create a REST API in Java platform with minimal installation and with minimal coding using Gradle and Spring Boot.

Steps

DIY

  • Install Gradle
  • Create a folder - say mkdir quickest-restapi.
  • Go inside that folder - i.e cd quickest-restapi
  • Run gradle init
  • You should have a bunch of gradle related files generated in this folder.
  • Open build.gradle
    • Uncomment the code - i.e. remove /* & */ comment characters.
    • Add the below lines into build.gradle file
      • Add spring-boot gradle plugin

        //Step-1: Spring boot plugin
        apply plugin: 'spring-boot'
        
      • Add dependencies for building the application.

        //Scripts/Components to use during Build
        buildscript {
        	repositories {
        		mavenCentral()
        	}
        	dependencies{
        		//Step-2: Spring boot plugin-package
        		classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.0.RELEASE")
        	}
        }
        
      • Add compile time dependencies in dependencies - not the dependencies under buildscript

        //Step-3: Spring boot starter web
        compile("org.springframework.boot:spring-boot-starter-web")
        
  • Create a Controller for REST API endpoints
  • Create a MainClass for the kick starting the REST API.
  • Run gradlew run
  • Access http://localhost:8080/ from your browser.

More DIY

  • Try adding compile("org.springframework.boot:spring-boot-starter-actuator") for more details about the Web Application you have created
    • Refer to the log file for more REST endpoints when the actuator is used
  • Try adding compile("org.springframework.boot:spring-boot-starter-data-jpa") and compile("org.hsqldb:hsqldb:2.3.1") and trial database code.
  • Try using apply plugin: 'jetty' and run gradlew jettyRun for executing the same in Jetty server

About

A quick start code & guide for using Spring Boot and build a simple REST API from ground up in few minutes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages