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
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Deploying a Spring Boot Microservice on AWS Fargate: Lessons From the Outage That Forced Me to Get It Right
  • 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

Trending

  • Building Enterprise Authentication With Angular, Spring Boot, SSO, and MFA
  • Reading GC Logs: Memory Leak or Undersized Heap?
  • The Cron Job Stopped and Nothing Turned Red
  • Article Moderation: Your Questions, Answered

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  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
·
Mar. 12, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
6.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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

  • Replacing JSON With Protobuf in Your Microservice Mesh: A Zero-Downtime Migration Blueprint
  • Deploying a Spring Boot Microservice on AWS Fargate: Lessons From the Outage That Forced Me to Get It Right
  • 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

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • 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