This guide will help you set up a Quarkus application with Hibernate ORM, creating REST endpoints and using a MYSQL database.
- Docker Desktop: Install Docker Desktop to run the PostgreSQL database.
- IDE: Use an Integrated Development Environment (IDE) like IntelliJ IDEA or Eclipse.
- Java Version: jdk 21
- Go to Quarkus Code Generator.
- Choose the necessary dependencies for your project:
- RESTEasy Classic
- RESTEasy Classic Jackson
- Quarkus Hibernate ORM Panache
- Quarkus JDBC MySql
- Quarkus Agroal
- Extract the generated project files.
- Open the project in your preferred IDE.
Create REST endpoints for basic CRUD operations (Create, Read, Update, Delete).
Add the following properties to src/main/resources/application.properties
:
quarkus.datasource.jdbc.url=jdbc:mysql://localhost:3306/my_db_movie
quarkus.datasource.username=username
quarkus.datasource.password=password
quarkus.datasource.db-kind=mysql
quarkus.hibernate-orm.database.generation=drop-and-create.
- Open a private command prompt for your project and run the following command
- docker run --name my_db_movie -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=my_db_movie -e MYSQL_USER=username -e MYSQL_PASSWORD=password -p 3306:3306 mysql:8.0
- Open a private command prompt for your project and run the following command
- mvn quarkus:dev
- Use Postman or any other HTTP client tool to test your REST endpoints.
- If you want to visualize your database schema and data, you can use DBeaver: Download and install DBeaver. Connect to your MySql database by providing the host (localhost), port (5432), username (username), password (password), and database name (my_db_movie).