Simplest SpringBoot Project Example

From NovaOrdis Knowledge Base
Revision as of 00:35, 7 February 2022 by Ovidiu (talk | contribs) (→‎Internal)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

Also see:

Writing a REST Service with Spring Boot

Example

settings.gradle

rootProject.name = 'simplest-spring-boot-example'

build.gradle

buildscript {
    ext {
        springBootVersion = '2.0.5.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'playground.simplest.springboot'
version = '0.0.1'
sourceCompatibility = 8

repositories {
    mavenCentral()
}

dependencies {

    implementation('org.projectlombok:lombok:1.18.2')
    implementation('org.springframework.boot:spring-boot-starter')
}


Main Class

...
@SpringBootApplication
public class MainApplication {

    public static void main(String[] args) throws Exception {

        SpringApplication.run(MainApplication.class, args);
    }
}

More details:

Spring Boot Main Class