5 Reasons You’ll ❤️ Using Micronaut and IntelliJ IDEA to Boost Your Productivity

Posted on by Zlata Kalyuzhnaya

This is a guest blog post from Iván López, one of the core members of the Micronaut and Grails development team at OCI

In November 2019, IntelliJ IDEA introduced support for Micronaut, making it even easier to build fast, lightweight microservices and serverless applications with the framework. As JetBrains continues to add more Micronaut features to IntelliJ IDEA, the Micronaut team at Object Computing finds that the two technologies work extremely well together.

Here are five specific features that make the Micronaut IntelliJ IDEA combo a terrific tool for any developer looking to boost his or her productivity.

Configuration Auto-Completion

Micronaut has published files containing the meta information for the configuration properties since 1.0. This file is generated automatically at compile time for any class annotated with @ConfigurationProperties or @EachProperty.

With this feature, you get auto-completion of the configuration properties in application.yml. This works not only for Micronaut itself, but for any configuration that you define in your own application.

For example, with the following immutable configuration in your project …


@ConfigurationProperties("my.engine")
public interface EngineConfig {

   /**
   * @return The manufacturer name.
   */
   @Bindable(defaultValue = "Ford")
   @NotBlank
   String getManufacturer();

   @Min(1L)
   int getCylinders();

   @NotNull
   CrankShaft getCrankShaft();

   @ConfigurationProperties("crank-shaft")
   interface CrankShaft {
       Optional getRodLength();
   }
}

… you get these auto-completions.

Even the default values for the properties and the javadoc comments are displayed.

auto-completion

Endpoints Discovery

You’re likely to find it really helpful to have a clear picture of all the endpoints in your application. You can click on the “Endpoint” button at the bottom of the screen to activate it.

There are a few configuration options to display exactly what you would like to see. These options include showing the endpoints from the framework (like management endpoints if you have them), grouping by client/server, and much more!

Additionally, if you double-click on an endpoint, the controller method is opened in the editor.

endpoints

Controllers and HTTP Requests

When interacting with our Micronaut applications, sometimes we use tools like curl to send HTTP requests. This is fine, but it means we must go “out” of our IDE, and we lose some of the features and shortcuts we’re used to.

Let’s imagine we have an encryption-service that receives some text and encrypts it. To make things simple, the encryption logic in the EncryptionService just reverses the string:

controller

If we click on the icon in the gutter, IntelliJ IDEA automatically generates an “http-requests” file with the endpoint set and ready to send a test request:

http-request

Take a look at the examples to see how to customize the requests, define authentication, and other useful tasks.

Event Publishing and Listeners

Sometimes we publish an event in our applications when something happens, and then we subscribe for that event in other parts of the code. But you may find it tricky to know exactly when that happens.

Not anymore!

Clicking on this new icon in the gutter navigates to the listener:

publish-event

listener

Miscellaneous

Besides the things I’ve already highlighted, other new features include new icons in the gutter, navigation to services injected as constructor arguments, and more.

JetBrains Conclusion

The Micronaut team has been extremely pleased with the superb efforts JetBrains has made in incorporating support for Micronaut into IntelliJ IDEA.

Next up: Support for Micronaut Data!

Micronaut Blog Conclusion

I’m really looking forward to support for Micronaut Data in a future IntelliJ IDEA release.

 

 

Comments below can no longer be edited.

2 Responses to 5 Reasons You’ll ❤️ Using Micronaut and IntelliJ IDEA to Boost Your Productivity

  1. Mike says:

    April 16, 2020

    Good stuff! As an aside; none of the links in the article seem to work, is this on purpose?

    • Zlata Kalyuzhnaya says:

      April 16, 2020

      Hi Mike! Thank you for noticing. Fixed it. All links are now working

Subscribe

Subscribe for updates