- OOP Principles (composition, inheritance, polymorphism, abstraction);
- Data Structures - Array, Deque, ArrayList, LinkedList;
- Third Party Libraries - Lombok and JDBC;
- Generic, anonymous classes. An anonymous class was made to extend a generic one;
- Optional class and Comparable in order to be able to avoid null pointer and to compare objects, Book object;
- SOLID design principles and template method pattern;
- Docker and MySQL 8.0;
- Fedora 38;
Project is 💯 completed!
👉 Here are the CRUD methods defined in the Data Access Object generic interface.
👉 This is the generic abstract class QueryTemplate that extends the ConnectionToDb to easily access the open/close connection and getConnection methods.
👉 For the link with DB we have an abstract class that is extended by various classes where we need the connection.
👉 With BookDAO we implement those CRUD operations, naive way is the first version which it's difficult to make tests for and the second one where I followed design pattern and SOLID principles in order to have a better build. With this class we extend the generic QueryTemplate one with an anonymous class.
-
Clone the repo:
git clone https://github.com/valentinsoare/LibraryWithCRUDInMind.git
-
Ensure that you have Docker and Docker-compose installed/
-
Make sure that you have the YML file called docker-compose.yml, and it is written to deploy the Mysql Server.
- Docker file:
version: '3.8' networks: default: services: db: image: mysql:8.0 container_name: library ports: - 3306:3306 volumes: - "./.data/db:/var/lib/mysql" environment: MYSQL_ROOT_PASSWORD: "XXXXX" MYSQL_DATABASE: "library_db"
-
Then please run
docker-compose up -d
in order to fetch the Mysql Server and deploy it. Then you can connect to it.
Note
It is recommended you modify the docker-compose.yml file but only the user and password for DB.
✅ For the pom.xml file we only have two dependencies (Lombok and JDBC) and
the necessary plugins for build (jar make) and download dependencies sources and documentation automatically.
- Dependencies
<dependencies>
<!-- LOMBOK -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
<scope>provided</scope>
</dependency>
<!-- JDBC Driver for MySQL -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
- Plugins
<plugins>
<!--_________________________________________________________________________________________________________-->
<!--Used to build JAR with dependencies inside....with command # mvn compile assembly:single-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.clibankinjava.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- To Download sources and documentation automatically-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<goals>
<goal>sources</goal>
<goal>resolve</goal>
</goals>
<configuration>
<classifier>javadoc</classifier>
</configuration>
</execution>
</executions>
</plugin>
<!--_________________________________________________________________________________________________________-->
</plugins>
Statistics
Social buttons
Repo metadata
Released under MIT by @valentinsoare 📫 Contact me