-
Notifications
You must be signed in to change notification settings - Fork 0
Setup Your Project
- You need to install Docker as we will be using a docker image of MariaDB Database.
To setup your database using the mariaDB image from docker. Run this command:
docker run --name db_Name -p 3306:3306 -v {THE_PATH_TO_STORE_DATA}:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mariadb:latest
This will create a docker container image on your system which you can use to connect with your database. The database server is running on Port #3306 as defined in the docker run command.
Now, every time you want to start your database server, run docker command
$ docker start db_Name
And your Server is ready to use
- In the Spring Tool Suite, you can either use our project by cloning it or create a new Maven Project.
- All your java program will be inside the package
/src/main/java - To connect your database (mariaDB image) to your spring application:
- Make a new file named
application.propertiesinside the package/src/main/resources - In this file, add the following code:
spring.jpa.hibernate.ddl-auto=update spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.username=root
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/{YOUR_DATABASE_NAME}
spring.datasource.password={password}
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB103Dialect