Spring and Spring Boot in IntelliJ IDEA 2018.1
Spring and Spring Boot in IntelliJ IDEA 2018.1
IntelliJ IDEA 2018.1 brings a variety of updates focused on the Spring ecosystem. Let's see what they are and how to make use of them.
Join the DZone community and get the full member experience.Join For Free
IntelliJ IDEA 2018.1 comes, as usual, with a lot of features to support developers who use Spring and Spring Boot. We also now have an OpenAPI for Spring Boot, which allows third-party plugins to re-use, integrate with or extend the existing Spring Boot support in IntelliJ IDEA.
IntelliJ IDEA 2018.1 fully supports Spring Boot 2.0, and the following features will work for Spring Boot 1.x as well as Spring Boot 2.0.
Spring Boot web applications are now easier to test and debug. Methods annotated with @RequestMapping or @GetMapping now have gutter icons that let you use the new REST client to make an HTTP request to the given URI.
In order to enable this, you must have a dependency upon the Spring Boot Actuator library, and the application also needs to be running.
To test a POST request, select “Open in HTTP Request Editor”, which opens a new scratch file with the appropriate URL. Changing the values in this scratch file lets you try out the request with different values. You can see not only the output, but the header values, response code, time taken, and other useful information about the response.
Methods annotated with @GetMapping also give the option to open this URL in the browser.
Check out the documentation for this feature.
Navigating through Bean declarations is now easier in IntelliJ IDEA 2018.1. Previously, the IDE showed all the beans in the Run Dashboard. This functionality has now been extended so you can navigate through the beans from within the editor – there are new gutter icons that show the beans that are relevant for the current class. Where appropriate, you can see where this class is injected and which beans it depends upon.
This feature also needs you to have the application running in order to work. Also, it only shows the beans that are registered in the running context.
IntelliJ IDEA 2018.1 has added the ability to rename caches. From cache annotations like @CacheEvict, @CachePut and @Cacheable, it’s possible to rename the cache and IntelliJ IDEA will make sure all uses of that cache are updated to the new name.
As you can see from the example above, this works not only with Java, but also Kotlin. Similarly, you’ll get SpEL code completion now for @Cacheable, @CacheEvict and @EventListener annotations when you’re using Kotlin.
A lot of work has gone into improving support for configuration files and improving and expanding auto-configuration. You’ll notice better performance, better code completion and suggestions, better organization of suggestions, and, of course, bug fixes too.
Another area that benefits from improved performance is diagrams. Large graphs and Spring diagrams in IntelliJ IDEA 2018.1 perform faster and use less memory.
Spring Boot Developer Tools
Spring Boot’s Developer Tools help developers get more rapid feedback and work more efficiently. IntelliJ IDEA 2018.1 has introduced some settings to reduce the code/deploy/test cycle when using Devtools.
If you’re running an application with Devtools enabled, there’s a new “Update” action which can trigger an application restart. You can configure what happens when you perform the update in the Run Configuration:
The following policies are available:
- Update resources: Update action performs resource update.
- Update classes and resources: Update action performs build.
- Update trigger file: Update action triggers an application restart by touching trigger file.
- Hot swap classes and update trigger file if failed: Update action performs build and hot swap. If hot swap is failed an application restart will be triggered by touching trigger file.
If you select either of the last two options, IntelliJ IDEA sets a trigger file when you start the application (it’s the equivalent of adding the VM option
In addition to this, IntelliJ IDEA 2018.1 also makes it easier to work with static assets and templates when using Devtools. In the same Run Configuration dialog, you can define what happens on On frame deactivation (e.g. when the editor loses focus). Selecting “Update resources” will automatically update static assets and templates.
Spring Security 5.0 and Spring Integration 5.0
Spring Integration 5.0 also contains new features, improvements and bug fixes. IntelliJ IDEA 2018.1 fully supports XML configuration for Spring integration, including all the new XML schemas introduced in this release.
IntelliJ IDEA 2018.1 has full support for the latest version of the Spring Framework and Spring Boot, improved performance when using these, and a new API to help third-party developers provide tools for working with Spring Boot.
More information about all the new features and bug fixes can be found in YouTrack.
Published at DZone with permission of Trisha Gee , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.