Simplest SpringBoot Project Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Spring Boot =Overview= =Example= ==settings.gradle== ==build.gradle== ==Main Class== More details: {{Spring_Boot_Concepts#Spring_B...")
 
 
(3 intermediate revisions by the same user not shown)
Line 2: Line 2:


* [[Spring_Boot#Overview|Spring Boot]]
* [[Spring_Boot#Overview|Spring Boot]]
* [[Writing_a_REST_Service_with_Spring_Boot#Overview|Writing a REST Service with Spring Boot]]


=Overview=
=Overview=
Also see: {{Internal|Writing_a_REST_Service_with_Spring_Boot#Overview|Writing a REST Service with Spring Boot}}


=Example=
=Example=


==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==


More details: {{Spring_Boot_Concepts#Spring_Boot_Main_Class|Spring Boot 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}}

Latest revision as of 00:35, 7 February 2022

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