Using SQL Changelogs with the Micronaut Liquibase library

1. Introduction Micronaut provides an integration with Liquibase to make it easy to manage database schema changes. This tutorial will show you can write your changelog files using SQL instead of XML. To begin you need to add the micronaut-liquibase dependency to your build.gradle file. implementation("io.micronaut.liquibase:micronaut-liquibase") 2. Configuration Set the schema-generation configuration for your datasource to NONE so that Micronaut Data does not attempt to generate the schema for you after the liquibase changelogs have been run.

Configuring HTTP to HTTPS redirects on AWS classic load balancer

If you have a Micronaut application deployed on AWS Elastic Beanstalk in an environment with a classic load balancer it is a straightforward process to redirect your HTTP traffic to HTTPS. Create a file named ./platform/nginx/conf.d/elasticbeanstalk/00_application.conf in the build file you upload to Elastic Beanstalk. location / { set $redirect 0; if ($http\_x\_forwarded\_proto != "https") { set $redirect 1; } if ($http\_user\_agent ~\* "ELB-HealthChecker") { set $redirect 0; } if ($redirect = 1) { return 301 https://$host$request\_uri; } proxy\_pass http://127.

How to bootstrap a Micronaut Vue SPA

Bootstrapping a Micronaut Vue Single Page Application is straightforward and similar to the approach you would take if doing with React. The result is a gradle multi project build consisting of a client and server subprojects. 1. Create client project In the client folder create a new Vue project using the vue-cli. Add the following build.gradle file. plugins { id "com.github.node-gradle.node" version "2.2.4" } node { version = '10.13.0' // https://nodejs.

How to use an embedded redis server with Micronaut

Micronaut provides support to use an embedded redis server which can be handy for running your tests. To run an embedded redis server you need to include the embedded redis dependency in your build.gradle file. testImplementation "com.github.kstyrc:embedded-redis:0.6" This will automatically start and the shutdown an embedded instance of Redis if none is available for the configured Redis URI. Micronaut achieves this by adding EmbeddedRedisServer which implements BeanCreatedEventListener and listens for the creation of the redis configuration.

How to log requests and responses in micronaut

Micronaut allows you to customize the Netty pipeline by using a bean event listener. You can therefore add custom channel handlers to the pipeline. Using this knowledge together with Logbook library you can easily log a request and the corresponding response. 1. Add logbook dependencies Add the Logbook dependencies logbook-core and logbook-netty to your build.gradle. implementation("org.zalando:logbook-core:2.3.0") implementation("org.zalando:logbook-netty:2.3.0") 2. Add the Logbook bean Create a bean of type Logbook via an @Factory annotated config class to be used by the pipeline customizer.

Using a random open port for tests in Micronaut

By default if the configuration property micronaut.server.port is not specified a Micronaut application will run on port 8080 and tests will run on a random port. If however you specify a port for the application to run on, your tests will also run on that port. For tests to run on a random port again you need to set micronaut.server.port to either -1 or ${random.port} in your application-test.yml config file. ${random.