Spring > Maven & Spring Boot

Spring Boot

The Spring Boot Maven plugin provides many convenient features:

  • It collects all the jars on the classpath and builds a single, runnable “über-jar”, which makes it more convenient to execute and transport your service.
  • It searches for the public static void main() method to flag as a runnable class.
  • It provides a built-in dependency resolver that sets the version number to match Spring Boot dependencies. You can override any version you wish, but it will default to Boot’s chosen set of versions.


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <artifactId>... name ...</artifactId> <!-- must-be-written-like-this -->
    <version>... version ...</version>
    <!-- Those don't seem to be mandatory -->

Simple Spring Boot application

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

@SpringBootApplication is a convenience annotation that adds all of the following:

  • @Configuration tags the class as a source of bean definitions for the application context.
  • @EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
  • @ComponentScan tells Spring to look for other components, configurations, and services in the the hello package.

Build & run

Run (dev)

mvn spring-boot:run


mvn clean package

Run (prod)

java -jar target/<build.finalName>.jar

Spring guides

Create source folder

mkdir src\main\java\hello

Create Eclipse project

mvn eclipse:eclipse