Simplest SpringBoot Project Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:


==settings.gradle==
==settings.gradle==
<syntaxhighlight lang='groovy'>
rootProject.name = 'simplest-spring-boot-example'
</syntaxhighlight>


==build.gradle==
==build.gradle==
<syntaxhighlight lang='groovy'>
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')
}
</syntaxhighlight>


==Main Class==
==Main Class==
<syntaxhighlight lang='java'>
...
@SpringBootApplication
public class MainApplication {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(MainApplication.class, args);
    }
}
</syntaxhighlight>


More details: {{Internal|Spring_Boot_Concepts#Spring_Boot_Main_Class|Spring Boot Main Class}}
More details: {{Internal|Spring_Boot_Concepts#Spring_Boot_Main_Class|Spring Boot Main Class}}

Revision as of 16:27, 2 November 2018

Internal

Overview

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