Just start typing...

Spring vs. Micronaut: we created two applications to find out which framework is better

Published September 14, 2022

Spring Framework has a lot of advantages when it is used for building Enterprise applications, but it may also have some disadvantages. For example, it can appear somewhat complicated, and it also consumes a lot of CPU resources. In this article we compare Spring with Micronaut and share the process and the results.  

Graeme Rocher, the author of Grails Framework, decided to create a new tool which would be more lightweight than Spring Framework. As a result of his experience in using Spring, Spring Boot and Grails, he eventually developed Micronaut Framework.

As specified on Micronaut's official website, it has a lot of advantages, e.g.:

  • Compatibility with Java, Groovy, and other JVM programming languages.
  • Fast database access configuration.
  • Simple unit tests creating.

Let’s look at the main differences between these frameworks more closely, and let’s decide which tool is better.

The main differences

These frameworks are quite similar in development. They both have DI support, configuring, creating APIs, and so on. For example, this is what creating a controller in Micronaut will look like:

public class DepartmentController {
private DepartmentService departmentService;

public List<DepartmentDto> findAll() {
return departmentService.findAll();


The Spring Framework annotation @Controller indicates that endpoints should return View (if they are not annotated with @ResponseBody). But in Micronaut, this annotation will return a mapped (in JSON) object. This approach looks more reasonable because in modern development, web pages are rarely rendered on the backend side.
The @Inject annotation is like @Autowired from Spring and allows inject dependencies through a class field. It is better to inject dependencies through a constructor or setter, which Micronaut can also do without any problems.


Micronaut has beans scope like Spring. However, their declarations slightly differ. To declare the scope of a bean in Spring, we need to write the @Scope annotation and indicate the scope in this annotation. But Micronaut has separate annotations for each scope – Singleton, Prototype, Context, ThreadLocal, Infrastructure, and Refreshable.

Application launch speed. Memory usage

As we mentioned before, the main aim of the creation of Micronaut was to make it lightweight, so that it could launch quickly. Let’s check and compare this. For that, we’ve created two simple applications with Web support via Spring and Micronaut.
Creating Micronaut project in IntelliJ IDEA is simple:

Related Services

How we process your personal data

When you submit the completed form, your personal data will be processed by WaveAccess Services. Due to our international presence, your data may be transferred and processed outside the country where you reside or are located. You have the right to withdraw your consent at any time.
Please read our Privacy Policy for more information.