1. Hello World in Bootique
The goal of this chapter is to write a simple REST app using Bootique. Let’s start with a new Java Maven project created in your favorite IDE. Your pom.xml
in addition to the required project information tags will need to declare a few BOM ("Bill of Material") imports in the <dependencyManagement/>
section:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.bootique.bom</groupId>
<artifactId>bootique-bom</artifactId>
<version>1.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
This will allow <dependencies/>
section that will follow shortly to include various Bootique modules and not worry about their individual versions. So let’s create this section and import a few modules:
<dependencies>
<dependency>
<groupId>io.bootique.jersey</groupId>
<artifactId>bootique-jersey</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.bootique.logback</groupId>
<artifactId>bootique-logback</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
As you see we want a bootique-jersey
and bootique-logback
modules in our app. Those may depend on other modules, but we don’t have to think about it. Those dependencies will be included by Maven automatically. Now let’s create the main Java class that will run the app:
package com.foo;
import io.bootique.Bootique;
public class Application {
public static void main(String[] args) {
Bootique
.app(args)
.autoLoadModules()
.exec()
.exit();
}
}
There’s only one line of meaningful code inside the main()
method, but this is already a working Bootique app. Meaning it is runnable and can do a few things. So let’s try r