DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Top Load Balancing Algorithms: Choosing the Right Strategy

Trending

  • MuleSoft MCP and A2A in Production: What 17 Recipes Reveal
  • A Deep Dive into Tracing Agentic Workflows (Part 2)
  • Encryption Won't Survive Quantum Computing: What to Do?
  • How to Interpret the Number of Spring ApplicationContexts in Integration Tests
  1. DZone
  2. Data Engineering
  3. Data
  4. Building Microservices With Micronaut

Building Microservices With Micronaut

For initial development, we are leveraging a JAX-RS based microservice-starter application similar to implementation using Oracle Helidon.

By 
Vinod Pahuja user avatar
Vinod Pahuja
·
Mar. 12, 20 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
6.7K Views

Join the DZone community and get the full member experience.

Join For Free

Micronaut is a modern, JVM-based, full-stack framework for building modular, easily testable microservice and serverless applications. 

For initial development, we are leveraging a JAX-RS based microservice-starter application similar to implementation using Oracle Helidon.

More about the lifecycle is explained below.

You may also like: A Quick Guide to Microservices With the Micronaut Framework

Packaging

Micronaut uses a maven shade plugin for packaging the application which put all the runtime dependencies an uber jar.

XML
 




x
20


 
1
<plugin>
2
  <groupId>org.apache.maven.plugins</groupId>
3
  <artifactId>maven-shade-plugin</artifactId>
4
    <executions>
5
      <execution>
6
      <phase>package</phase>
7
      <goals>
8
        <goal>shade</goal>
9
      </goals>
10
        <configuration>
11
          <transformers>
12
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
13
              <mainClass>${mainClass}</mainClass>
14
            </transformer>
15
          <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
16
        </transformers>
17
      </configuration>
18
    </execution>
19
  </executions>
20
</plugin>



Deployment

Micronaut supports HTTP deployment based on netty server and partial/compatible support for JAX-RS resources.

XML
 




xxxxxxxxxx
1
15


 
1
<dependencies>
2
  <dependency>
3
    <groupId>io.micronaut.jaxrs</groupId>
4
    <artifactId>micronaut-jaxrs-server</artifactId>
5
    <version>1.0.0.M1</version>
6
  </dependency>
7
  <dependency>
8
    <groupId>io.micronaut</groupId>
9
    <artifactId>micronaut-runtime</artifactId>
10
  </dependency>
11
  <dependency>
12
    <groupId>io.micronaut</groupId>
13
    <artifactId>micronaut-http-server-netty</artifactId>
14
    </dependency>
15
</dependencies>



In addition to these, it required additional plugins/dependencies at the compile phase to process its annotations.

XML
 




xxxxxxxxxx
1
14


 
1
<annotationProcessorPaths>
2
  <path>
3
    <groupId>io.micronaut</groupId>
4
    <artifactId>micronaut-inject-java</artifactId>
5
  </path>
6
  <path>
7
    <groupId>io.micronaut</groupId>
8
    <artifactId>micronaut-validation</artifactId>
9
  </path>
10
  <path>
11
    <groupId>io.micronaut.jaxrs</groupId>
12
    <artifactId>micronaut-jaxrs-processor</artifactId>
13
  </path>
14
</annotationProcessorPaths>



Launcher

Micronaut provides a build-in runner class that can be invoked through the main class.

Java
 




xxxxxxxxxx
1


 
1
public class Application {
2
    public static void main(String[] args) {
3
        Micronaut.run(Application.class);
4
    }
5
}



Which can be a trigger in multiple ways.

Dev

mvn exec:java

Prod

java - jar target/microservice-starter-micronaut.jar

The complete example can found here at microservice-starter-microanaut.


Further Reading

Micronaut Tutorial: Server Application

microservice

Opinions expressed by DZone contributors are their own.

Related

  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Design and Implementation of Cloud-Native Microservice Architectures for Scalable Insurance Analytics Platforms
  • Top Load Balancing Algorithms: Choosing the Right Strategy

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook