What’s New in IntelliJ IDEA 2023.1 for Spring Developers
The IntelliJ IDEA 2023.1 release came packed with updates for Spring. This blog post will highlight the most noticeable changes, including full support for Lombok, a reworked Spring tool window, navigation for Spring Security rules, Spring Security 6 support, and more.
Remember that these features are only available in IntelliJ IDEA Ultimate.
Let’s take a look!
Full support for Lombok with Spring
Many developers like to use Lombok when working with the Spring framework. With v2023.1, we have added full support for all of Lombok’s helpful features, making your experience much more enjoyable and productive.
For instance, if you use Lombok’s RequiredArgsConstructor on bean classes, you can now navigate to autowired dependencies or candidates right from a field’s gutter icon.
Our inspections now also work with any Lombok-annotated Spring bean.
Additionally, IntelliJ IDEA now proposes a quick-fix for missing bean dependencies that takes Lombok annotations into account.
Reworked Spring tool window
The Spring tool window got a significant redesign to accompany the IDE-wide UI enhancements. Once you activate the new UI via Preferences/Settings | Appearance & Behavior | New UI, you can open the updated Spring tool window in two different ways:
- Hover over Go to … in the left-hand pane and select the Spring leaf.
- Click on the icon in the gutter and choose Select in Spring View.
The open tool window now has a minimalist appearance while still providing lots of information. More specifically, the window is now aligned vertically and appears as a simple list of Spring beans. You can search and filter the list according to your needs. The new view is much faster, which is particularly noticeable when working on large projects.
Incorrect transactional method call detection
One of known pitfalls of @Transactional usage in Spring is when such methods are accidentally called from within the bean itself. IntelliJ IDEA now shows warnings if you’re going to bypass the transactional proxy by calling the method directly.
Navigation for Spring Security rules
If your project uses Spring Security rules, the IDE detects all of the places where they are applied and lets you navigate to and from them.
In the gif below, you can see how clicking on a URL that comes with a security rule and selecting Show security configurations for URL brings us to the security matchers.
From there, you can return to the controller by clicking on the shield icon and selecting Navigate to secured URL.
Spring Security 6 support
It is now possible to use code completion and navigate to URL mappings and security roles for APIs that were introduced in Spring Security 6, such as AbstractRequestMatcherRegistry.requestMatchers and HttpSecurity.securityMatcher.
Running MongoDB queries in the Database console from Spring Data repositories
If you have Spring repositories that contain MongoDB queries, you can now easily run the latter from the Database console. This is very convenient when you want to check whether a query works and what the result is after running it.
In the example below, we press ⌥ Enter (macOS) or Alt + Enter (Windows or Linux) and select the Run query in console action from the list. The MongoDB query then appears in the Database console, where it can be edited and run with the triangle button.
When you edit queries, code completion works inside them, allowing you to compose more complex ones quickly.
In the following gif, we show how to get a list of people aged 25 and older with the help of $gt.
Recognition of Swagger annotations for OpenAPI generation
Previously IntelliJ IDEA didn’t take into consideration Swagger 2.X annotations that you could use in Spring controllers. Starting from v2023.1, IntelliJ IDEA now takes them into consideration when generating OpenAPI.
To see how this works, add the @Operation annotation and define the desired additional properties for your method. For example, you can add an ID and a description for it, and make it deprecated. Then click the URL next to the desired method and select Generate OpenAPI draft from the list. You will see that the annotation is considered in the generated YAML file and its effect is visible in the OpenAPI preview.
Thanks for reading about the most prominent updates for Spring in v2023.1! Give them a try when working with Spring in IntelliJ IDEA. You can find more enhancements described on our What’s New page. If you think there are features that are missing and you would like us to add them, please let us know in the comments to this post.
Subscribe to Blog updates
Thanks, we've got you!