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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Growth and Demand for Low Code Development
  • Java Server Faces in Real-Life Applications
  • Power BI Embedded Analytics — Part 3: Power BI Embedded Demo
  • DGS GraphQL and Spring Boot

Trending

  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  • How to Merge HTML Documents in Java
  • Monoliths, REST, and Spring Boot Sidecars: A Real Modernization Playbook
  • Simpler Data Transfer Objects With Java Records
  1. DZone
  2. Culture and Methodologies
  3. Methodologies
  4. Micronaut: Rapid Development With MicrostarterCLI

Micronaut: Rapid Development With MicrostarterCLI

MicrostarterCLI is a rapid development tool for Micronaut applications. In this article, we will demonstrate how it makes developing GraphQL services easy.

By 
Ahmed Al-Hashmi user avatar
Ahmed Al-Hashmi
·
Apr. 18, 22 · Tutorial
Likes (9)
Comment
Save
Tweet
Share
6.7K Views

Join the DZone community and get the full member experience.

Join For Free

MicrostarterCLI is a rapid development tool for Micronaut applications. It helps you as a developer to generate standard reusable codes, configurations, or patterns as you need in your application. 

Application Description

In this article, we will develop an ArabicNames service that has REST and GraphQL endpoints. To begin with the development, we will generate a Micronaut application project from Micronaut Launch. Then, we will use MicrostarterCLI to develop the following: 

  1. ArabicName entity class.
  2. JDBC repository and Service classes for the Arabic Entity Class. 
  3. REST and GraphQL endpoints to consume the Arabic Name services.
  4. Liquibase migration file.
  5. TestClass to test Arabic Name REST endpoints.

ArabicName Entity Attributes

Attribute
Data Type description
letter String English letter
name String The name in English
nativeArabic String The name is Arabic
meaning String The name's meaning in English

Let's Do It 

Step 1:  Visit https://micronaut.io/launch and generate a Micronaut application with a language of your choice. You can add the features you need for the Arabic Names service, but MicrostarterCLI will add all the required features if you don't add them from Micronaut Launch. 

In this article, I'll generate the project as follows: 

Micronaut Application
Application Type
Micronaut Application
Java Version
11
Name
ArabicNames
package
io.hashimati.dzone
Micronaut Version
Latest
language
Java
Build Tool
Gradle
Test Framework
JUnit

Step 2: Download the MicrostarterCLI release zip file. Then, unzip it and copy the mc.jar, mc.bat, and mc files to the root of the project's folder. 

https://github.com/hashimati/MicrostarterCli/releases/tag/v0.1.1

Step 3: Go to the project directory from the terminal/command prompt and run the "configure" command: 

Shell
 
mc configure

The "configure" command will take you through a step-by-step process to add the project's dependencies with their necessary configuration and the database information. The dependencies include:

  • Port Number: The default port value is 8080
  • Reactive Framework: Reactor, RxJava2, or RxJava3
  • Database Type Dependencies: MongoDB, H2, MySQL, Oracle, MariaDB, Postgres, or SQL Server  
  • Database Access Framework: Micronaut Data, ReactiveMongo, or Gorm
  • Database Migration Tool: Liquibase or Flyway
  • Messaging: Kafka, RabbitMQ, NATs.io, or GCP-PubSub 
  • Caching: Caffeine
  • Micrometers
  • Tracing: Jaeger or Zipkin
  • GraphQL: GraphQL Java Kickstart
  • OpenAPI: MicrostarterCLI will add this dependency by default. 

We will do the configuration as follows:

Step 4: Run the "entity" command to generate the ArabicName's entity, repository, service, controller, test-controller, client, GraphQL files, and Liquibase files.

Shell
 
mc entity -e ArabicName --graphql

When the command starts, it will ask you to enter the collection's name or the table. Then, it will prompt you to enter the attributes. Add the attributes as the following table: 

Attribute Type Validation FindBy() Method FindAllBy() Method UpdateBy() Method
Name String - Yes No Yes
letter String - No Yes No
NativeArabic String - Yes No No
Meaning String - No No No

Step 5: Open the project with your favorite IDE and check the generated files.

Step 6: Run the "gradlew test" command to run a JUnit test for the ArabicName REST endpoints. 

Shell
 
gradlew test

Step 7: Run the "gradlew run" command to run the application.  

Step 8: Try the REST services using OpenAPI. The OpenAPI is accessible on this URL: http://localhost:8080/swagger/views/swagger-ui/index.html. 

We will save the below object by calling "http://localhost:8080/api/v1/arabicName/save".

 
{
	"name": "Abbas",
	"letter": "A",
	"nativeArabic": "عباس",
	"meaning": "Another name for a lion. The lion that the lions flee from"
}

Step 9: Try the GraphQL services. Open "http://localhost:8080/graphiql". Retrieve all Arabic Names objects by calling the below query.

Markdown
 
query{
  findAllArabicName{
    name, 
    letter, 
    nativeArabic, 
    meaning
  }
}


Conclusion

MicrostarterCLI is a progressive rapid development tool, and it has a lot of features that cut development time and remove the burden of the configuration. I'll try to cover the MicrostarterCLI features in more depth in subsequent articles. The source code for this project is available here. 

Happy coding!

Rapid application development application

Opinions expressed by DZone contributors are their own.

Related

  • Growth and Demand for Low Code Development
  • Java Server Faces in Real-Life Applications
  • Power BI Embedded Analytics — Part 3: Power BI Embedded Demo
  • DGS GraphQL and Spring Boot

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!