
application.properties file:
spring.datasource.url=jdbc:mysql://localhost:3306/nobsv2
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
use nobsv2;
CREATE TABLE product( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255), description VARCHAR(255), price DOUBLE );
INSERT INTO product (name, description, price) VALUES
('Apple iPhone 14', 'Latest model with 256GB storage A15 Bionic chip, and improved camera system', 999.99), ('Samsung Galaxy S21', 'Flagship phone with 128GB storage, Exynos 2100, and triple camera setup', 799.99), ('Sony HW-1000XM4', 'Wireless noise-cancelling headphones with up to 30 hours of battery life', 3499.99);
select * from product;
The latest version of IntelliJ is not processing annotations correctly. This is a known issue and there is an open ticket on IntelliJ's website (I even commented on it). In the meantime, to avoid a [{},{},{}] error you may get in postman when pinging the findAllProducts API -> just remove Lombok's @Data annotation and replace it with Getters, Setters, and a Constructor.
CREATE TABLE address (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
street VARCHAR(255),
city VARCHAR(255),
state VARCHAR(255) );
CREATE TABLE customer (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(255),
last_name VARCHAR(255),
address_id BIGINT, FOREIGN KEY (address_id) REFERENCES address(id) );
INSERT INTO address (street, city, state) VALUES ('123 Main St', 'Cityville', 'CA');
INSERT INTO customer (first_name, last_name, address_id) VALUES ('John', 'Doe', 1);
ALTER TABLE address
ADD COLUMN customer_id BIGINT,
ADD CONSTRAINT fk_customer
FOREIGN KEY (customer_id)
REFERENCES customer (id);
UPDATE address
SET customer_id = (SELECT id FROM customer WHERE id = address.id);
INSERT INTO customer (first_name, last_name) VALUES ('Jane', 'Smith');
INSERT INTO address (street, city, state, customer_id)
VALUES ('789 Pine St', 'CityC', 'SC', 1), ('101 Elm St', 'CityD', 'SC', 2);
**run after testing complete**
ALTER TABLE customer
DROP FOREIGN KEY customer_ibfk_1;
ALTER TABLE customer
DROP COLUMN address_id;
CREATE TABLE customer_address (
customer_id BIGINT,
address_id BIGINT,
PRIMARY KEY (customer_id, address_id),
FOREIGN KEY (customer_id) REFERENCES customer(id),
FOREIGN KEY (address_id) REFERENCES address(id) );
INSERT INTO customer_address (customer_id, address_id)
SELECT customer_id, id as address_id
FROM address;
**test before running these**
ALTER TABLE address
DROP FOREIGN KEY fk_customer;
ALTER TABLE address
DROP COLUMN customer_id;
logging.file.name=mylog.log
This comprehensive course is designed to transition Java developers into proficient backend engineers by mastering the essentials of Spring Boot. Unlike other courses that dive into complex concepts before covering the basics, this course follows a hands-on, real-world approach. We focus on building practical applications using live production code techniques, modern Java abstractions, and clear naming conventions commonly used in industry projects.
You’ll start by understanding how Spring Boot works before diving into the why—giving you the tools to build solid foundations before exploring advanced topics. Whether you’re new to Spring Boot or looking to solidify your backend skills, this course offers a straightforward, no-nonsense guide that covers all the essential components needed for building scalable, production-ready applications.
What You Will Learn:
Controllers, Services, Repositories, and Entities: Understand the core building blocks of Spring Boot applications, including how to set up RESTful APIs, business logic layers, and data access layers.
Database Integration with MySQL: Learn how to run MySQL queries, set up database connections, and work seamlessly with relational databases.
Exception Handling & Custom Error Responses: Master best practices for handling errors, defining custom error responses, and returning meaningful error messages in production.
Input Validation: Implement input validation to ensure data integrity, and protect against invalid requests
Spring Data JPA & Custom Queries: Explore query string parameters, custom query methods with @Query, and interact with databases using Spring Data JPA.
JDBC, JPA, and Hibernate: Learn the differences between JDBC and JPA, understand ORM (Object Relational Mapping) with Hibernate, and when to use each in your applications.
Unit Testing: Write unit tests to ensure your code works as expected, covering both service and repository layers using tools like JUnit and Mockito.
Working with HTTP Headers: Learn how to work with request and response headers, implement custom headers, and pass data effectively through API endpoints.
Relational Mappings (OneToOne, OneToMany, ManyToMany): Understand how to model real-world relationships between entities in a relational database using JPA annotations.
Logging: Implement effective logging strategies to track application behavior, debug issues, and monitor performance.
Caching for Performance Optimization: Leverage caching strategies to improve application performance and scalability, including setting up default caching and custom cache eviction policies.
External API Integration: Learn how to consume external APIs, handle authentication, and integrate third-party services into your Spring Boot application.
Spring Security: Explore the built-in security mechanisms, set up Basic Authentication, and secure your applications with JWT (JSON Web Token) for token-based authentication.
Dependency Injection & Inversion of Control (IoC): Gain a solid understanding of how Spring Boot manages dependencies and objects, ensuring modular and maintainable code.
Monitoring with Spring Boot Actuator: Enable real-time monitoring of your application, track performance metrics, and expose health and status endpoints using Spring Boot’s Actuator.
Transactions & @Transactional: Manage database transactions, understand transactional boundaries, and ensure data consistency using Spring’s @Transactional annotation.
Advanced Java Concepts in Spring Boot: Delve into practical Java topics frequently used in Spring Boot applications, such as UUIDs for unique identifiers, event-driven programming, handling various return types, managing JSON data in MySQL, and implementing versioning for your APIs.