Micronaut application in heroku

We are going to build a simple micronaut application using gradle and deploy in heroku.

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

Gradle is an open-source build automation tool that is designed to be flexible enough to build almost any type of software.

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.

Create a new micronaut application

Lets create an application using micronaut launch

Micronaut Launch is a web application that allows you to create Micronaut projects through an interface instead of using the console CLI.

Micronaut Launch

generate project .

1. push to your github account
2. download locally as zip
3. use micronaut cli commands to create locally

we are going with option 2 .

Now lets create our our first controller, create a new package : resource

Create a new class DemoResource which is a controller

Add a get method which takes name n returns string

Once the class is added , let’s build and run the application and test our endpoint

Now our simple micronaut application in ready and working as expected

Deploy the application to heroku

If you don’t have a Heroku account yet you can create your free account by going to the Heroku signup page .

Now lets make our application ready for deployment in heroku

Java Version

By default heroku use jdk 8 .

If you are using any other version , need to create a file system.properties

and have property a property defining java version to be used

check https://devcenter.heroku.com/articles/java-support#supported-java-versions


By default heroku runs a gradle task “stage” which is clean build and need a manifest file


Heroku needs a file known a Procfile to run the application. Create the file and make an entry.

Heroku runs the application on a random port. So pass the value in the proc file. $PORT is auto replaced heroku during deploy.

Now our application is ready to be deployed to Heroku.

Deploy the application to heroku

We will communicate to heroku using command line. We have have to install the Heroku cli. The installation guide for the Heroku cli https://devcenter.heroku.com/articles/heroku-cli

Once installed, verify installation

With the Heroku cli you can login to Heroku with the following command.

Now lets create our application in heroku

We are using heroku git here. But we can connect to github.

Once pushed, the application is deployed

Now let check our application logs to verify if its running

Now lets try our endpoint

There we have our micronaut application deployed in heroku.

In the next post lets add postgres database as an add-on to the demo project.

Happy Learning.



Software engineer, technology enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store