Skip to content

This project manages an employee database with CRUD operations and is deployed on Alibaba Cloud using Terraform for scalable infrastructure management

Notifications You must be signed in to change notification settings

SaraKhild/springboot-thymeleaf-crud-db-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot & Thymeleaf: CRUD Operations with Database Integration and Deployment on Alibaba Cloud


Overview

This project focuses on managing an employee database through a user-friendly interface. It includes functionalities to:

  • Display a list of employees.
  • Add new employees to the database.
  • Update existing employee information.
  • Delete employees from the database.

The project also incorporates cloud deployment using Alibaba Cloud. Infrastructure is provisioned and managed using Terraform, enabling scalable and efficient deployment of the application.


Usages

  • SpringBoot
  • SpringJPA
  • Thymeleaf
  • MySQL
  • Terraform
  • Dockerfile
  • Docekr Compose

Architecture of the Project

1- deployment folders

  • provider.tf
  • vpc.tf
  • key.tf
  • bastion-sg.t
  • bastion.tf
  • employee-sg.tf
  • employee.tf
  • employee.tpl
  • mysql-sg.tf
  • mysql.tf
  • mysql.tpl
  • load-balancer.tf

2- src folders

2.1 main

  • Controllers folder
  • Entities folder
  • DAO folder
  • Services folder

2.2 resources

2.2.1 templates
  • employee-form.html
  • list-employees.html

2-Maven pom.xml


 <dependencies>

        <!-- thymeleaf engin for html -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!-- spring mvc includs RES support -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- dev tool for reload server automatic when change code -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <!-- mysql deriver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <!-- Hibernate -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

</dependencies>

3-Application.properties.yml

spring.datasource.url=jdbc:mysql://mydb:3306/demo
spring.datasource.username=demouser
spring.datasource.password=demopass

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update  

4- Dockerfile

FROM  openjdk:17
WORKDIR /
ADD target/spring-boot-thymeleaf-crud-db-project-0.0.1-SNAPSHOT.jar /
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/spring-boot-thymeleaf-crud-db-project-0.0.1-SNAPSHOT.jar"]

5- Docker-compose.yml

version: "3"
services:
  server:
    container_name: app-container
    image: app-image
    build: .
    restart: always
    ports:
      - 9091:8080
    depends_on: 
      - mydb

  mydb:
    container_name: mydb
    platform: linux/arm64/v8
    image: mysql:latest
    restart: always
    ports:
      - 3313:3306
    environment:
      MYSQL_DATABASE: demo
      MYSQL_USER: demouser
      MYSQL_PASSWORD: demopass
      MYSQL_ROOT_PASSWORD: demopass

Let's Start 🦾

• Display Empoyees Table


display-employee

• Add new Employee


add-employee

add-employee

• Update Empoyee:


update-employee

update-employee

• Delete Employee:


delete-employee

delete-employee


Good Luck

About

This project manages an employee database with CRUD operations and is deployed on Alibaba Cloud using Terraform for scalable infrastructure management

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published