3. Getting Started

Let’s create a first project and discover the various options that you can use to tune it. Go to start.spring.io, change the Group field from "com.example" to "org.acme" and put the focus in the Dependencies field on the right hand side. If you type "web", you will see a list of matching choices with that simple criteria. Use the mouse or the arrow keys and Enter to select the "Web" starter.

Your browser should now be in this state:

Browser
[Note]Note

The Spring Boot version above probably doesn’t match the one you have. As we will see later, start.spring.io is continuously updated as new Spring Boot versions are published and the service uses the latest version by default.

Click on Generate Project, this downloads a zip file containing a Maven project with the following structure:

mvnw
mvnw.cmd
pom.xml
src
├── main
│   ├── java
│   │   └── org
│   │       └── acme
│   │           └── DemoApplication.java
│   └── resources
│       ├── application.properties
│       ├── static
│       └── templates
└── test
    └── java
        └── org
            └── acme
                └── DemoApplicationTests.java

A typical project generated by Spring Initializr contains a Spring Boot application (DemoApplication), a test and an empty configuration. If you run the main method of DemoApplication, you’ll see an "empty" spring boot app starting on localhost:8080.

Because Spring Initializr has detected it is a web application, a static and templates directories have been created to hold your static resources and ui templates.

Also, a Maven wrapper is automatically included so that you don’t have to install Maven to run this project (you can build it with ./mvnw install). If you prefer, you can select Gradle instead in the first drop down list at the top of the screen. This will generate a Gradle-based project instead that also contains a wrapper if you don’t have Gradle installed (build it with ./gradlew build).

3.1 Advanced options

Next to the Generate Project you’ll find a "Switch to the full version" link. If you click on that, you’ll see all the available options. Let’s browse through them quickly:

  • Group: project coordinates (id of the project’s group, as referred by the groupId attribute in Apache Maven). Also infers the root package name to use.
  • Artifact: project coordinates (id of the artifact, as referred by the artifactId attribute in Apache Maven). Also infers the name of the project
  • Name: display name of the project that also determines the name of your Spring Boot application. For instance, if the name of your project is my-app, the generated project will have a MyAppApplication class
  • Description: description of the project
  • Package Name: root package of the project. If not specified, the value of the Group attribute is used
  • Packaging: project packaging (as referred by the concept of the same name in Apache Maven). start.spring.io can generate jar or war projects
  • Java Version: the Java version to use
  • Language: the programming language to use

If you keep on scrolling, you’ll discover all the dependencies that you can find using the search box on the right. You’ll probably notice that some dependencies are greyed out in the UI, meaning that they aren’t available because they require a specific Spring Boot version. We’ll tackle that in the next section.

3.2 Dependencies

The UI allows you to select the Spring Boot version you want to use. You may want to be conservative and keep the default which corresponds at all times to the latest stable release. Or you may want to chose a milestone or snapshot of the next major version. Either way, you’ll notice that certain dependencies become available and others aren’t anymore when you change the version.

If you are searching for a dependency that you know to be available and you get no result, it’s worth looking in the advanced section if that dependency is available in the Spring Boot version that is currently selected.

You may find it is not the case with a message that looks like the following:

requires Spring Boot >=1.0.0.RELEASE and <1.5.0.RC1

Concretely, this defines a "version range" that states the dependency is deprecated and is no longer available as of Spring Boot 1.5. You may want to check the release notes of the related project to understand what your migration path can be. Alternatively, the message could be:

requires Spring Boot >=2.0.0.RELEASE

That version range means the dependency is not available with the current Spring Boot generation. Obviously, if you select Spring Boot 2.0 (or later if available), you’ll be able to select that dependency.

3.3 Tuning default values

The Initializr service is configured to offer default values so that you can generate a new project with minimum fuss. Maybe you are a Kotlin fan? Or a Gradle fan? Currently start.spring.io defaults to Java and Maven but it also allows you to tune these defaults easily.

You can share or bookmark URLs that will automatically customize form inputs. For instance, the following URL changes the default to use Kotlin and Gradle:

https://start.spring.io/#!language=kotlin&type=gradle-project

The following attributes are supported:

  • Programming language: language (java, groovy or kotlin)
  • Java version: javaVersion (1.6, 1.7, 1.8)
  • Project type: type (maven-project, gradle-project)
  • Packaging: packaging (jar, war)
  • Group: groupId
  • Artifact: artifactId
  • Name: name
  • Description: description
  • Package Name: packageName
[Tip]Tip

The same default rules will apply if a property is overridden. For instance, if the Group is customized, it will automatically customize the root package as well.

[Note]Note

The Spring Boot version and the list of dependencies cannot be customized that way as they evolve quite frequently.