Spring Boot REST API Anti-Patterns and Best Practices
Vložit
- čas přidán 15. 07. 2024
- #sivalabs #spring #springboot #intellij #productivity #java #testing #junit #junit5 #maven #jpa #hibernate #unittesting
In this video, I will explain what are some of the common anti-patterns used in Spring Boot REST API development and how to fix them by following best practices.
Timestamps
00:00:00 Introduction
00:03:10 Existing REST API walk-through
00:06:42 Not following REST conventions
00:18:57 Using Field Injection
00:28:42 Not using pagination
00:36:00 Not using request-specific payload bindings
00:45:42 Using JPA DDL auto-generation
00:53:18 Misusing Spring Data JPA derived-query method names
00:57:23 Loading entire entities and using only a small subset of fields
01:03:00 Using JPA that results in N+1 Select problems
01:09:36 Not implementing proper Exception Handling
01:15:48 Using @SpringBootTest for testing slices (controller, repository)
01:21:35 Testing with in-memory database
01:29:01 Not using proper package structure
References
=============================================
⭐ Source Code: github.com/sivaprasadreddy/si...
⭐ Spring Boot Tutorials: www.sivalabs.in/spring-boot-t...
⭐ Tomato Architecture - A Pragmatic Approach to Software Design: www.sivalabs.in/tomato-archit...
⭐ Modular Monoliths • Simon Brown: • Modular Monoliths • Si...
Connect with Me
=============================================
Blog: www.sivalabs.in
CZcams: / sivalabs
Twitter: / sivalabs
GitHub: github.com/sivaprasadreddy
LinkedIn: / ksivaprasadreddy
Popular Series Playlists
=============================================
🚀 🎬 Spring Boot Tips Series Playlist • Spring Boot Tips
🚀 🎬 Spring Boot + Kubernetes Tutorial Series Playlist • Spring Boot + Kubernet...
🚀 🎬 Spring Boot - The Missing Guide Series Playlist • Spring Boot - The Miss...
🚀 🎬 Integration Testing with Testcontainers • Integration Testing wi...
🚀 🎬 Java Testing Made Easy Playlist • Java Testing Made Easy...
⭐ Tags ⭐
best spring tutorials, best spring boot tutorials, how to learn spring boot, mastering spring boot, complete java testing course, java testing best practices, how to build spring boot rest API, spring cloud tutorials, spring boot docker tutorial, spring boot Kubernetes tutorial, how to become proficient in java, how to learn spring boot quickly, how to learn spring boot in-depth - Věda a technologie
Useful tutorial things!
Amazing thank you brother !!
Thank you si a for the wonderful effort
I've an enhancement on the pagination request you could use the
one based index instead of subtracting to be zero by just providing the property on the application propertise
spring:
data:
web:
pageable:
one-indexed-parameters: true
Only the first topic covers "Rest". Url naming patterns and certain status codes are not mandatory to be restful. Only a uniform interface.
production-ready is also highly claimed too --> hence reworded as is the DONE #productEconomy scale ready
Sir, kindly make the tutorial over Servlet JSP JDBC so that our prerequisites are clear.
Can i do a post for getting things if i have a nested hierarchy like a category inside multiple categories, then brand inside multiple brands, then size where I'll be having lot of sizes. So if i want to pass multiple categories, brands, and sizes to get info
REST principles are more of guidelines than rules. Sometimes we have to use POST for getting the information due to the payload limitation of GET request. For example Elasticsearch uses POST for fetching matching documents.