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
BUILD SUCCESSFUL in 28s
./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;

@Controller
@Slf4j
public class DemoResource {

@Get
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
java.runtime.version=17.0.2
jar {
manifest {
attributes(
'Main-Class': 'com.micronaut.demo.Application'
)
}
}


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

build.mustRunAfter clean
micronaut:
application:
name: micronautHerokuDemo

server:
port: ${PORT:8080}
cors:
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:
remote: -----> Compressing...
remote: Done: 137.7M
remote: -----> Launching...
remote: Released v3
remote: https://micronaut-heroku-demo.herokuapp.com/ deployed to Heroku
remote:
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

--

--

--

Software engineer, technology enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Visualise surface charges of your protein 3D structure

Surface charges of a protein at two different pH’s. Colour ramp from blue to red, reflects negative to positive charge.

LNK: A perfect vector for living-off-the-land attacks

The Ultimate Cheat Sheet On IBM i Application Modernization

How Kotlin can cover for the shortcomings of Java? — A Developer’s Outlook

Android App Development with Kotlin — Systango Blog

Creating a Pressure Pad

System Design Capstone Day 4

How we enabled our Sales to build and price custom coverages

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
Irfan Ali Shaik

Irfan Ali Shaik

Software engineer, technology enthusiast

More from Medium

Encrypting and Decrypting a message using Asymmetric Keys with Java, explained step-by-step with…

DB-Lock-Issues with Transactional REQUIRES_NEW — More Spring/Java transaction handling pitfalls

no string-argument constructor/factory method to deserialize from string value

Object-relational Mapping Using JPA Hibernate and Spring Data JPA. Persistence with Spring Data JPA