#21 Project using Spring | Project Setup with Model

#21 Project using Spring | Project Setup with Model

Building the Backend for an E-commerce Application

Setting Up the Project

  • The session focuses on building the backend for an e-commerce application after completing the frontend.
  • A new Spring Boot web project is created with Maven, using Java version 21 and group ID comiso.
  • Key dependencies include Spring Web, JPA for database connectivity, Dev Tools for fast reload, Lombok for boilerplate code reduction, and H2 as a lightweight database.

Initial Configuration

  • The project is unzipped and opened in IntelliJ IDEA Community Edition; default port number set to 8080.
  • Before making changes, it's essential to check if port 8080 is available; it runs successfully on port 880.

Database Setup

  • Database properties are configured: setting up URL for H2 database and specifying driver class name.
  • JPA settings are adjusted to show SQL queries during execution; table creation options are discussed (create vs. update).

Defining Product Model

  • Discussion on defining product attributes such as ID (primary key), name, description, brand, price (as BigDecimal), category, release date (formatted), availability (Boolean), and quantity.
  • A model package structure is established to organize classes effectively; a product class will be created with specified attributes.

Creating Controller and Testing Endpoints

  • A simple REST controller named ProductController is created with a greeting method returning "Hello World" at the base API endpoint.
  • Testing the endpoint via Postman or browser confirms that the application responds correctly with "Hello World".

Finalizing Product Class Structure

  • The product class is defined with all necessary properties using Lombok annotations for automatic getter/setter generation.
  • The product entity must be annotated properly so that JPA recognizes it as a database entity.

Verifying Database Table Creation

  • After running the application again, verification of table creation in H2 console shows correct structure but no data yet present.

Conclusion of Current Session

  • The session concludes by confirming that the project structure is ready; future sessions will focus on adding data to populate tables.
Video description

Git Repo : https://github.com/navinreddy20/spring6yt React code : https://github.com/navinreddy20/ecom-frontend-1 Check out our courses: Mastering Agentic AI with Java: Spring AI, LangChain4j, MCP & ADK: https://go.telusko.com/agentic-ai Coupon: TELUSKO10 (10% Discount) DevOps Bootcamp: https://go.telusko.com/complete-devops Coupon: TELUSKO10 (10% Discount) Master Java Spring Development : https://go.telusko.com/learn-master Coupon: TELUSKO10 (10% Discount) For More Queries WhatsApp or Call on : +919008963671 website : https://telusko.com/ Udemy Courses: Java Spring:- https://go.telusko.com/Udemyjavaspring Java:- https://go.telusko.com/udemyteluskojava Spring: https://go.telusko.com/udemyteluskospring Java For Programmers:- https://go.telusko.com/javaProgrammers Python : https://go.telusko.com/udemyteluskopython Git : https://go.telusko.com/udemyteluskogit Docker : https://go.telusko.com/udemyteluskodocker Instagram : https://www.instagram.com/navinreddyofficial/ Linkedin : https://in.linkedin.com/in/navinreddy20 WhatsApp : https://go.telusko.com/whatsapp TELUSKO Android App : https://go.telusko.com/TELUSKOAPP TELUSKO IOS App : https://apple.co/3SsgmU2 Discord : https://discord.gg/D8hWe9BqfF