This project is for learning purpose. EVERY DATA IN THE SQL FILE IS JUST FOR LEARNING PURPOSE. YOU ARE FREE TO USE IT FOR YOUR OWN PURPOSE. But, if you want to use it for commercial purposes, please recreate your own sql database. It's not a production ready.
Big Project about Book Management with Java OOP (Learining purpose)
-
bgsix: Is the team name: Big Group Six (Nhóm 6)
-
Members:
- Trần Thành Long (Leader) neilfranci
- Nguyễn Vũ Hải Đăng nguyendang3002
- Vũ Văn Sơn sunyn582
-
SPHM: Spring Postgresql Htmx Maven (the technology stack)
- Install the Postgresql
- Adding necessary program to path
- Creating a database
- Importing the database
- Install maven
- Install GraalVM native-image (Java SDK replacement)
Install Pre-requisite for GraalVM native-image (Production)
- Open the .env.template file in this path
- Running the server (Development)
- Building self-contained jar (Production)
Building the native image (Production)
1.1 After press install, and next.
1.2 You now in "Select Components" part
1.3 Uncheck Stack Builder
1.4 press next, until you meet password for superuser type your own password
default port is 5432
1.5 keep pressing next until it in "Installing" part.
1.6 Wait for it done, and Finish. DONE!
Default install path is:
C:\Program Files\PostgreSQL\16\bin
Open system enviroment variable on Windows.
- Double click on the Path in the system section
- Click on new
- Paste the path
- CLick OK
- Open the command prompt or powershell
psql -V
# Output : psql (PostgreSQL) 16.4
- Create a database
createdb -U postgres book-management
enter your password from #1.4
We using the default superuser "postgres" here
psql -U postgres
# then in the console
postgres=#
# type \l (not the number 1)
postgres=# \l
\q to quit the console or Ctrl + C
- Example output
script\drcrim.cmd password
- password is the password from #1.4
-
Open the Terminal in the project folder (root) follow this
-
The book-management.sql is in the root of the project (using relative path to import the database)
-
If
book-management.sql
is in the root of the project then run this command
psql -U postgres -f .\book-management.sql book-management
---------^username----^file path----------- ^database name
- Verify the database is imported
psql -U postgres -d book-management
# then in the console
SELECT author FROM book LIMIT 5; # to see the data
-
Download maven from https://maven.apache.org/download.cgi
- Binary zip archive apache-maven-3.9.9-bin.zip
-
Extract the zip file to the desired location
- Example:
C:\apache-maven-3.9.9
(make sure there is a folderbin
in theapache-maven-3.9.9
folder)
- Example:
-
Add the maven path to the system environment variable
- Open the environment variable
- Double Click on the
Path
in the user section - Click on new
- Paste the path
C:\apache-maven-3.9.9\bin
- Click OK
-
Verify the maven installation
mvn -v
# Output : Apache Maven 3.9.9
-
Download GraalVM from https://www.graalvm.org/downloads/
- Make sure to choose Java 22 version and Windows 64 bit
-
Extract the zip file to the desired location
- Example:
C:\Program Files\Java\graalvm-jdk-22.0.2+9.1\bin
(make sure there is a folderbin
in thegraalvm-jdk-22.0.2+9.1
folder)
- Example:
-
Add the GraalVM path to the system environment variable
- Open the environment variable
- Double Click on the
Path
in the user section - Click on new
- Paste the path
C:\Program Files\Java\graalvm-jdk-22.0.2+9.1\bin
- Click OK
-
Verify the GraalVM installation
java -version
# Output :
# java version "22.0.2" 2024-07-16
# Java(TM) SE Runtime Environment Oracle GraalVM 22.0.2+9.1 (build 22.0.2+9-jvmci-b01)
# Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 22.0.2+9.1 (build 22.0.2+9-jvmci-b01, mixed mode, sharing)
- Follow the instruction from https://www.graalvm.org/latest/docs/getting-started/windows/#prerequisites-for-native-image-on-windows
git clone https://github.com/neilfranci/book-management-SJPM.git
2.1 VSCode
cd to the project folder
cd book-management-SJPM
then open the project in vscode with this command
code .
install vs code extension for java https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack
then wait for the extension to install
mvn clean install
-
create a new file
.env
in the root and copy the content from.env.template
to.env
-
replace the value with your own value
mvn spring-boot:run
mvn clean package
-
this will create a jar file in the target folder
/target/bookmanagement-{version}.jar
-
then to run jar file:
java -jar target/bookmanagement-{version}.jar
mvn clean package -Pnative
- then run the executable file in the target folder
.\taget
(the native image is a single file) in this case the file is `bookmanagement.exe
Answer: Just drop the database
dropdb -U postgres book-management
Answer: Data Transfer Object (DTO) is a design pattern used to transfer data between data access objects and value objects. The data is transferred in the form of data transfer objects. DATABASE Class > Repository Class > Service Class > Controller Class > DTO Class > Sendalbe Data to Client