Java REST API Showdown: Which is the Best Framework on the Market?

Java REST API Showdown: Which is the Best Framework on the Market?

A Quick Guide to creating REST APIs with popular Java frameworks: Micronaut, Quarkus, and Spring Boot.

Fasil

Can you add Vert.x and Microprofile to the list. My thought is Microprofile needs more attention because it’s implemented over standard REST specifications.

graemerocher

Nice article, the difference in startup for Micronaut vs the other implementations is that Micronaut is making the web service call to Okta to configure the routes for login and callback during startup which leads to this inefficiency and different in timings.

We are working on a new version of the Micronaut Security module that improves this behaviour so that the frameworks can be compared on a level playing field. Thanks for the feedback.

Sergio del Amo

To validate a JWT with a remote Json web key set you don’t need to add the Oauth 2.0 module in the Micronaut app. I have created a PR which illustrates the simplification. https://github.com/oktadeve…

John Clingan

@Fasil, Quarkus is using the MicroProfile APIs. It’s kinda hidden behind the scenes, but this Quarkus app is using MicroProfile Config and MicroProfile JWT (see application.properties settings). Also somewhat hidden is the fact that the Quarkus MicroProfile JWT RBAC implementation uses vertx and vertx web. Yes, Quarkus uses Vert.x under the hood in many areas.

Stuart Douglas

Is that Quarkus time running quarkus:dev or running the production application (‘java -jar target/quarkus-1.0-SNAPSHOT-runner.jar’)?

Quarkus production mode is a lot faster to start than dev mode, as a lot of the work is done at build time. Dev mode allows for live changes, so needs to load a lot more classes and perform a lot more work to start the app (it essentially generates a new app on startup/restart).

Matt Raible

I used the same commands that are used in this post, which means I used ./mvnw compile quarkus:dev for Quarkus. I didn’t count how many seconds elapsed from the time I ran the command, I just copied the value that the console printed out. As a developer, I’m not that concerned about how fast it starts in production mode since I probably wouldn’t use that much.

Matt Raible

Hello Graeme! I believe all the implementations make a web service call since all they’re all configured with an issuer. It does seem strange that Micronaut and Quarkus require defining the keys endpoint too. That’s defined in the issuer’s well-known endpoint, and you’d think they could just look it up. For example, it’s the jwks_uri in https://dev-133320.okta.com/oauth2/default/.well-known/openid-configuration.

Genene Geda

Your conclusion on startup performance is wrong. Based on your data below, Spring Boot is the fastest , not micronaut … (wrong data, perhaps ?):
Micronaut: 1985ms
Quarkus: 1.156s
Spring Boot: 1.127 seconds

Matt Raible

You are correct. However, if you create native images (with Graal) of the Quarkus and Micronaut apps, they’ll start faster. Spring Boot has experimental Graal support, but it’s not as mature as Quarkus and Micronaut.

Darren Bell

Now show how to implement Basic auth using LDAP and a JWT token in each of the 3. We are using micronaut and required zero code to do this, only some config and a @Secured annotation. We tried this in Spring and had to write quite a bit of code. The benefits of using a newer framework are not about raw times, but also developer speed, which we have to found to be greatly increased.

Shawn Ashe

Guess I can’t get past step 1… plugin:register worked, but
mvn com.okta:okta-maven-plugin:spring-boot

Just crashes out with a "failed to execute goal com.okta:okta-maven-plugin:0.4.0:spring-boot … where it cant find a suitable constructor…
1 error
role: org.apache.maven.plugin.Mojo

Am I missing another dependency?

Matt Raible

What version of Maven are you using? You might need to upgrade.

Shawn Ashe

java-1.8.0-openjdk-1.8.0.275.b01-0.el7_9.x86_64
Apache Maven 3.0.5 (Red Hat 3.0.5-17)

Fresh install of Centos 7… do I need to pull maven from apache directly?

Matt Raible

The Okta Maven Plugin docs don’t specify a version, but I’ve used Maven version 3.6.3 successfully.

Dmitry Kornilov

It would great to include Helidon to the comparison.