This section describes the configuration structure that is used by the initializr. The metadata provided through configuration are driving the options exposed by a particular instance and the project metadata format.
Tip | |
---|---|
A good way to get started with the configuration is to look at the configuration of the production instance and check the end-result on start.spring.io |
The configuration is split in several sections:
env
section used to provide various global settings.dependencies
section lists the available dependencies. This is the most
important section of the service as it defines the "libraries" that the user can
choose.groupId
, artifactId
, version
, name
, description
and packageName
provide default values for these project settings.types
, packagings
, javaVersions
, languages
and bootVersions
provide
the list of available option for each setting and which one is the default.Tip | |
---|---|
Check the code for a full list of the available configuration options. |
The env
element defines environment option that the service uses:
artifactRepository
: the URL of the (maven) repository that should be used to
download the Spring Boot CLI distribution bundle. This is only used by the /spring
endpoint at the moment.springBootMetadataUrl
the URL of the resource that provides the list of available
Spring Boot versions..forceSsl
: a boolean flag that determines if we should use https
even when
browsing a resource via http
. This is enabled by default.fallbackApplicationName
: the name of the default application. Application names
are generated based on the project’s name. However, some user input may result in an
invalid identifier for a Java class name for instance.invalidApplicationNames
: a fixed list of invalid application names. If a project
generation uses one of these names, the fallback is used instead.invalidPackageNames
: a fixed list of invalid package names. If a project
generation uses one of these names, the default is used instead.googleAnalyticsTrackingCode
: the Google Analytics code to use. If this is set,
Google analytics is automatically enabled.kotlin
: kotlin-specific settings. For now, only the kotlin version to use can be
configured.maven
: maven-specified settings. A custom maven parent POM can be defined and
whether or not the spring-boot-dependencies
BOM should be automatically added to
the project.If some of your dependencies require a custom Bill of Materials (BOM) and/or a custom
repository, you can add them here and use the id as a reference. For instance, let’s
say that you want to integrate with library foo
and it requires a foo-bom
and a
foo-repo
. You can configure things as follows:
initializr: env: boms: foo-bom: groupId: com.example artifactId: foo-bom version: 1.2.3 repositories: foo-repo: name: foo-release-repo url: https://repo.example.com/foo snapshotsEnabled: false
You can then use the foo-bom
and foo-repo
in a "dependency" or "dependency group"
section.
Note | |
---|---|
The |
The dependencies
section allows you define a list of groups, each group having one
more dependency
. A group gather dependencies that share a common characteristics
(i.e. all web-related dependencies for instance).
A dependency
has the following basic characteristics:
name
and description
used in the generated meta-data and the web ui.groupId
and artifactId
to define the coordinates of the dependency.version
if Spring Boot does not already provide a dependency management for
that dependency.scope
(can be compile
, runtime
, provided
or test
).bom
or a repository
that must be added to the project once
that dependency is added.versionRange
used to determine the Spring Boot versions that are compatible
with the dependency.Tip | |
---|---|
Check the code for a full list of the available configuration options. |
Here is the most basic dependency entry you could have
initializr: dependencies: - name: Core content: - id: security name: Security description: Secure your application via spring-security
Tip | |
---|---|
The |
This adds an option name Security
with a tooltip showing the description above. If
a project is generated with that dependency, the
org.springframework.boot:spring-boot-starter-security
dependency will be added to
the project.
Let’s now add a custom dependency that is not managed by Spring Boot and that only
work from Spring Boot 1.2.0.RELEASE
and onwards but should not be used in the 1.3
lines and further for some reason.
initializr: dependencies: - name: Core content: - id: my-lib-id name: My lib description: Secure your application via spring-security groupId: com.example.foo artifactId: foo-core bom: foo-bom repository: foo-repo versionRange: "[1.2.0.RELEASE,1.3.0.M1)"
If one selects this entry, the com.example.foo:foo-core}
dependency will be added
and the Bill of Materials and repository for foo
will be added automatically to
the project as well (see the "Env section" above for a reference to those
identifiers). Because the bom provides a dependency management for foo-core
there
is no need to hard code the version in the configuration.
The versionRange
syntax follows some simple rules: a square bracket "[" or "]"
denotes an inclusive end of the range and a round bracket "(" or ")" denotes an
exclusive end of the range. A range can also be unbounded by defining a a single
version. In the example above, the dependency will be available as from
1.2.0.RELEASE
up to, not included, 1.3.0.M1
(which is the first milestone of the
1.3 line).
The other section defines the default and the list of available options in the web UI. This also drives how the meta-data for your instance are generated and tooling support is meant to react to that.
For instance, if you want your groupId to default to org.acme
and the
javaVersions
to only be 1.7
and 1.8
you would write the following config:
initializr: groupId: value: org.acme javaVersions: - id: 1.8 default: true - id: 1.7 default: false