How to Run Startup Code When Micronaut Starts

When building applications with Micronaut, we often need to execute some logic when the application starts. This could include tasks like initializing resources, seeding a database, or logging system information. In this article, we will explore how to run startup code in Micronaut using ApplicationEventListener and @EventListener. Table of contents 1. Implements ApplicationEventListener to Run …

Read more

How to run an init script for Docker MariaDB

The official Docker mariadb image will run all *.sh and *.sql scripts in its /docker-entrypoint-initdb.d directory automatically when it starts. Table of contents: 1. Create an init.sql 2. Run an init script for Docker MariaDB 3. Access the MariaDB running container 4. References Technologies used: Docker 24.0.5 Official Docker mariadb image (latest tag) 1. Create …

Read more

How to run an init script for Docker Postgres

The official Docker postgres image will run all *.sh and *.sql scripts in its /docker-entrypoint-initdb.d directory automatically when it starts. Table of contents: 1. Create an init.sql 2. Copy init.sql to container 3. Start the Postgres container 4. Access the Postgres container 5. References Technologies used: Docker 24.0.5 Official Docker postgres image (latest) 1. Create …

Read more