Micronaut application in heroku

Micronaut Launch
Application type : micronaut application, version: latest ( 3.3.0) when writing this postLanguage: java, version: 17Build tool: gradle ( 7.3.1) when writing this post.test framework: junitselect features you would like
we are going with basic features: lombok, logback
update name and base package: micronaut-heroku-demo and com.micronaut.demo
Unzip the archive ( mac,linux)
unzip micronaut-heroku-demo.zip -d micronaut-heroku-demo
cd micronaut-heroku-demoBuild:./gradlew clean build
Launch:./gradlew run

./gradlew clean build
./gradlew run
Startup completed in 342ms. Server Running: http://localhost:8080
package com.micronaut.demo.resource;

import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.QueryValue;
import lombok.extern.slf4j.Slf4j;

import javax.validation.constraints.NotNull;

public class DemoResource {

public String getGreetings(@QueryValue @NotNull String name){

log.info("sending greetings to {}",name);

return "Hello %s from demo application".formatted(name);
curl -- location -- request GET 'http://localhost:8080/?name=irfan'
Hello irfan from demo application
jar {
manifest {
'Main-Class': 'com.micronaut.demo.Application'

task stage(dependsOn: ['build', 'clean'])

build.mustRunAfter clean
name: micronautHerokuDemo

port: ${PORT:8080}
enabled: true
web: java $JAVA_OPTS -Dmicronaut.environments=heroku -Dserver.port=$PORT -jar build/libs/micronaut-heroku-demo-0.1-all.jar
brew tap heroku/brew && brew install heroku
heroku --version
heroku/7.59.2 darwin-x64 node-v12.21.0
heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/*************
Logging in... done
Logged in as *****@****.com
heroku apps:create micronaut-heroku-demo
Creating ⬢ micronaut-heroku-demo... done
https://micronaut-heroku-demo.herokuapp.com/ | https://git.heroku.com/micronaut-heroku-demo.git
git init

heroku git:remote -a micronaut-heroku-demo

git add .

git commit -am "make it better"

git push heroku master
remote: BUILD SUCCESSFUL in 48s
remote: 15 actionable tasks: 15 executed
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote: -----> Compressing...
remote: Done: 137.7M
remote: -----> Launching...
remote: Released v3
remote: https://micronaut-heroku-demo.herokuapp.com/ deployed to Heroku
remote: Verifying deploy... done.
heroku logs --app micronaut-heroku-demo --tail[main] INFO  i.m.context.env.DefaultEnvironment - Established active environments: [cloud, heroku]
app[web.1]: 16:45:22.854 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 3305ms. Server Running: http://localhost:56410
heroku[web.1]: State changed from starting to up
Build succeeded
curl --location --request GET 'https://micronaut-heroku-demo.herokuapp.com/?name=irfan'
Hello irfan from demo application



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