There was a 'Not Found' error fetching URL: 'https://twitter.com/antonarhipov/status/978748331525640192'
That’s one nifty feature, among others. If you’re developing with Spring Boot, IntelliJ IDEA does offer a lot more niceties to speed up development time. Let’s browse through some of them.
Project creation with the Initializr
Usually, creating a Spring Boot project requires:
- Going to the online Spring Initializr
- Selecting a few options
- Downloading the project archive
- Extracting the archive
- Importing it into the IDE
IntelliJ IDEA makes it a lot simpler by providing a GUI through which to do the previous steps. Go to
. Select Spring Initializr and follow the wizard.
The wizard doesn’t work offline, it requires access to start.spring.io (or at least access to the Spring Initializr instance used). |
Spring Boot run/debug configurations
It’s perfectly possible to use a standard Application configuration to run Spring Boot applications.
However, the dedicated Spring Boot configuration allows specific options:
- Enable debug output
- Hide Banner
- Enable launch optimization
- Enable JMX agent
- Set Active Profiles
- Override parameters
To create such a configuration, go to
. Then, on the right top corner, click on the + button. Finally, fill in the fields adequately.Application configuration properties auto-completion
In the application.properties
file, standard properties can be auto-completed.
For example, if one starts typing "log", available options will be displayed automatically.
Even better, IntelliJ IDEA warns if a property is not recognized.
A property is "recognized" if an associated It will work for your own if you package the Properties class and the configuration files within your JAR. |
Application configuration YAML auto-completion
application.yml
benefits from the same auto-completion feature as properties.
Application configuration files setter
Context files of regular Spring projects can be set in the project settings.
Spring Boot configuration properties can be also set, in case the default application.properties
is not the right fit.
Right-click on the project. Choose Open Module Settings…. In the opening window, select
. Click on the Spring Boot icon at the bottom.
The pattern of the application configuration file can set to override the default one.
This is different than setting the application configuration files are runtime. This allows IntelliJ IDEA to manage it at compile-time. |
Actuator integration
I believe that the Actuator is one of the best feature in Spring Boot, if not the best. IntelliJ IDEA offers a great integration of it.
The Run dashboard is able to display a lot of data, taken from the Actuator:
- Beans
-
- Health
-
- Controller mappings
-
Triggering DevTools
This is not an integration feature, but rather a workaround I found. |
DevTools is a dependency that allows to update a Spring Boot app during development without restarting the whole Tomcat (and more). It works by detecting when a class is compiled and replaced and reloading part of the context. By default, IntelliJ IDEA saves automatically changed files but doesn’t compile (as opposed to Eclipse which requires saving explicitly but then compiles).
Thus, to trigger reloading, one needs to click every time on the Build Project button. Instead, I assigned a keyboard shortcut i.e. ⌘+Shift+S which emulates Eclipse behavior.
Conclusion
While Spring Tools Suite is the "official" Spring IDE, IntelliJ IDEA offers a lot of niceties that speed up Spring Boot applications development time.