This project is intent to be a sample for MicroProfile with Redis single node integration by using Jakarta NoSQL implementation.
Redis is a software project that implements data structure servers. It is open-source, networked, in-memory, and stores keys with optional durability.
The project is configured to reach out a Redis instance with the following configuration defined on the file src/main/resources/META-INF/microprofile-config.properties
. More info about it, check the following link: https://github.com/eclipse/jnosql-databases?tab=readme-ov-file#configuration-14
link:src/main/resources/META-INF/microprofile-config.properties[role=include]
PS:warning: Pay attention to that when you try to set up your own Redis instance.
The easier way to execute this project is to use the provided docker-compose.yaml file in the root directory. You can run it by performing the following command:
docker-compose up -d
Follow the instructions in: https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/
-
Install docker: https://www.docker.com/
-
Run docker command
docker run -d --name redis-instance -p 6379:6379 redis
The generation of the executable jar file can be performed by issuing the following command
mvn clean package
This will create an executable jar file microprofile-liberty-redis.jar within the target maven folder. This can be started by executing the following command
java -jar target/microprofile-liberty-redis.jar
During development, you can use Liberty’s development mode (dev mode) to code while observing and testing your changes on the fly. With the dev mode, you can code along and watch the change reflected in the running server right away; unit and integration tests are run on pressing Enter in the command terminal; you can attach a debugger to the running server at any time to step through your code.
mvn liberty:dev
To launch the test page, open your browser at the following URL
http://localhost:9080/index.html
By default, there is always the creation of a JAX-RS application class to define the path on which the JAX-RS endpoints are available.
Also, a simple Hello world endpoint is created, have a look at the class HelloController.
More information on MicroProfile can be found [here](https://microprofile.io/)
Configuration of your application parameters. Specification [here](https://microprofile.io/project/eclipse/microprofile-config)
The example class ConfigTestController shows you how to inject a configuration parameter and how you can retrieve it programmatically.