This repository demonstrates Spring Boot R2DBC MySQL support
MySQL R2DBC Spring Boot 2.7.x
This repository demonstrates Spring Boot R2DBC MySQL support
Steps
Step 1
Simple databaseClient use: SELECT 1
query with local mysql in docker.
Check v0-simple-database-client-select-with-mysql-in-docker
tag for details
Getting started
Run and test latest’s code:
if [[ "" != `docker ps -aq` ]] ; then docker rm -f -v `docker ps -aq` ; fi
docker run -d --rm --name mysql --platform=linux/x86_64 \
--health-cmd='mysqladmin ping -h 127.0.0.1 -u $MYSQL_USER --password=$MYSQL_PASSWORD || exit 1' \
--health-start-period=1s --health-retries=1111 --health-interval=1s --health-timeout=5s \
-e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=database \
-e MYSQL_USER=user -e MYSQL_PASSWORD=password \
-p 3306:3306 \
mysql:8.0.24
while [[ $(docker ps -n 1 -q -f health=healthy -f status=running | wc -l) -lt 1 ]] ; do sleep 3 ; echo -n '.' ; done ; sleep 15; echo 'MySQL is ready.'
./mvnw
docker stop mysql
Release
Create and push git tag to park some piece of completed work, for example:
git tag v0-simple-database-client-select-with-mysql-in-docker
git pso --tags
Reference Documentation
- Spring boot glob resources:
ResourcePatternUtils.getResourcePatternResolver(resourceLoader) .getResources("classpath:*/db/migrations/*.ddl.sql") .sort { r1, r2 -> "${r1.url}".compareTo("${r2.url}") } .forEach { prontln(it) } // will print: // /path/to/db/migrations/V202205281525_drop_table_if_exists_messages.ddl.sql // /path/to/db/migrations/V202205281526_create_table_if_not_exists_messages.ddl.sql // /path/to/db/migrations/V202205281527_create_index_messages_sent_at_idx.ddl.sql
- Spring boot glob resources, see 1: org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources
- Spring boot glob resources, see 2: org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources
- Spring boot glob resources, see 3: org.springframework.core.io.support.ResourcePatternUtils.getResourcePatternResolver
- Spring boot glob resources, see 4: org.springframework.core.io.support.ResourcePatternResolver.getResources
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Coroutines section of the Spring Framework Documentation
- Spring Configuration Processor
- Spring Data R2DBC
- Spring Reactive Web
- Accessing data with MySQL
- Acessing data with R2DBC
- Building a Reactive RESTful Web Service
- R2DBC Homepage
- Make sure to include a R2DBC Driver to connect to your database.