Skip to content

Instantly share code, notes, and snippets.

@rajasharan
Last active July 21, 2018 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajasharan/c776c6e900f89b9720b012d9a13847f0 to your computer and use it in GitHub Desktop.
Save rajasharan/c776c6e900f89b9720b012d9a13847f0 to your computer and use it in GitHub Desktop.
Spring-boot hands-on lab

Step 0 - Verify java & mvn are installed on the system

  • $ java -version
  • $ mvn -version

Step 1 - Generate simple maven archetype project

$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false 

Step 2 - Configure maven compiler plugin

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

Step 3 - Inherit spring-boot parent

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
</parent>

Step 4 - Add spring-boot starter pack (for e.g *-web)

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Step 5 - Setup spring-boot build plugin

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Step 6 - Springify the app with @SpringBootApplication

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

Step 7 - Test the app

$ mvn clean install
$ java -jar target\my-app-*.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment