ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
Creating Java REST API with Spring Boot , Spring Data JPA and MySQL | REST API CRUD Operations
ฝัง
- เผยแพร่เมื่อ 5 ส.ค. 2024
- Connecting Spring Boot Application with Database can be daunting for Java developers.
Hence, let us learn how to build and connect Java REST API with Spring Boot , Spring Data JPA and MySQL, extremely helpful for backend java developers. In this session, CRUD will be implemented and data will be stored in MySQL database. Data will also be updated, fetched and deleted from mysql.
We will learn how to configure MySQL database for Spring Boot REST API using application.yaml and implement Service and Repository patterns for establishing communication between Spring Boot REST API and MySQL database. Spring Boot Project code structure for REST API is explained. Finally application will be tested by Postman tool and MySQL Workbench. Data exchange format will be used as JSON.
Some key Spring Boot and Spring JPA annotations -
@SpringBootApplication , @RestController , @RequestBody , @RequestMapping , @GetMapping , @PostMapping , @PutMapping , @DeleteMapping , @Entity , @Table, @Id , @Service, @Override
Spring Boot REST API project with data persistence in the MySQL for Cloud Vendor Information Service with all 4 CRUD operations are developed in this session.
Spring data JPA and Spring Boot methods save() , findById(), findAll(), deleteById() are used.
CRUD operations will be implemented in this session with saving, fetching/ querying and deleting data from MySQL database.
Spring Boot is widely used for developing Microservices.
GitHub repository link for the Cloud Vendor Service Code is -
github.com/thinkconstructive/...
Session for Controller Layer operations - Create, Read, Update and Delete - All 4 REST API CRUD operations are implemented in below session. Kindly refer below link -
• Java REST API with Spr...
Java Spring Boot with MySQL using Spring Data JPA Tutorial with custom method is mentioned below -
• Java Spring Boot with ...
Kindly subscribe to the channel for getting regular updates of the new sessions on Software / Computer Application topics by clicking below link -
/ @thinkconstructive
Follow me on -
- Official Website: thinkconstructive.com/
- Twitter: / tconstructive
- LinkedIn: / eshapuri
Some Good Books -
Atomic Habits - amzn.to/3yEzGU5
Rich Dad Poor Dad - amzn.to/3LhaG87
Disclosure, I use affiliate Amazon links above. Purchasing through these links gives me a small commission to support videos on this channel -- the price to you is the same.
Chapters
00:00:00 Welcome Note
00:01:07 Recap - Spring Boot, Spring Data JPA and MySQL
00:03:23 Cloud Vendor Scenario , REST API and Client Explanation
00:04:34 Spring Boot REST API Project Structure Explanation
00:08:42 Create Spring Boot Project using Spring Initializer with all Dependencies
00:11:13 pom.xml Dependencies
00:14:35 Create and Configure application.yaml / application.yml
00:18:07 MySQL Workbench Schema Verification
00:19:31 Maven Dependency refresh
00:19:53 Add @Entitiy , @Table and @Id Annotations to Model Class
00:22:32 Controller Layer Explanation
00:24:37 Create Repository with JpaRepository
00:27:22 Create Service Interface for CRUD and GetAll
00:31:52 Service Implementation @Service - CRUD and GetAll methods Implementation
00:41:21 Implement Controller CRUD and GetAll methods
00:49:33 Starting Spring Boot Application
00:50:22 Detailed testing Create , Read , Update , Delete ( CRUD ) and ReadAll using Postman and MySQL Workbench
01:00:09 Summary
01:02:57 Thank You Note
#springboot #restapi #java #thinkconstructive #eshapuri
Queries
how to build spring boot application
how to implement rest api using spring boot
how to implement java rest api using spring boot
how to implement crud operations using rest api and spring boot
how to implement crud operations using java rest api and spring boot
how to connect mysql with spring boot
how to connect mysql with spring boot and spring data jpa
how to store data in mysql using spring boot rest api
how to test rest api with postman
how to test crud rest api
how to use spring initializer
what is spring boot
what is rest api
what is postman
what is mysql workbench
how to create application.yaml
how to create application.yml
how to configure application.yaml
how to fetch data from mysql and spring boot
what is spring boot rest api project architecture
how to arrange spring boot rest api code
what is controller layer
what is service layer
what is repository layer
how to write getall rest api with spring boot
how to write get rest api with spring boot
how to write delete rest api with spring boot
how to write create rest api with spring boot
how to write update rest api with spring boot
Java REST API with Spring Boot, Spring Data JPA and MySQL covers Create, Read, Update, Delete i.e. CRUD Operations will ReadAll / GetAll operations in detail. This tutorial covers detailed explanation along with thorough demonstration and then tested using Postman and MySQL Workbench. This will definitely be very helpful for those who are looking learn Java REST API with Spring Boot and MySQL database.
This is a high in demand skill; hence this session will definitely be beneficial for you.
Enjoy learning.
Cheers,
Esha
Thank you so much madam.
Thank you for this video, it is really helpful.
I have a doubt , what if cloud vendor info table is having addition and deletion of columns on daily basis. How can I address this scenario
Mother is the biggest guru in the world. Whenever I watch your tutorial, I feel like my mom is teaching me Java,
so mam, whatever playlist of Spring Boot Microservices you have,
you can completed all springboot with microservices the playlist. Please do it,
And I have learned a lot from your TH-cam channel and want to learn further,
so please post the complete tutorial of Spring Boot Microservices,
complete this course, add all these videos like Jenkins, Kubernetility, dockers etc.
in the playlist, I will not go outside anywhere else.
Excellent video. Whole CRUD operation explained in such a clear and informative way. Very useful for someone to get complete flow of Java Rest API framework.
Thank you. Glad it was helpful 😊
Thank you so much , I'm grateful for having such a content freely !
never found so much good tutorial on whole youtube ...your r the best of best teachers i have came across till now...
Thank you Madam for a breif explanation ..It is a complete practical video of Java rest ful api development using Spring boot framework,testing Postman and MySQL workbench .
Kudos to you for creating a such a informative tutorial.
I found that the delete API is also giving 200 OK response even for the vendorId not present in the database. Also even I request delete for same vendorId again, it also gives success message.
Best tutorial on spring boot found till date, please create videos on microservices and kafka also after completing this playlist.
This is the best video I've seen on Spring Boot. Thank You Ma'am.
Glad that it was helpful 😊
Please share with other too. Thanks 😊
Namaste. Thank you for the tutorial.
thank you so much
after watching so many videos .this video gave me clear understanding of the concepts
I want to say big thanks. This tutorial saved me a lot of time and gave me a great example. Keep up the good work and the well-earned subscribe and like!
Happy to know that it helped you and I earned a fantastic subscriber 😊
Stay connected and please share with others too. Thank you 😊
So valuable content, thanks a lot ma'am
Thank you so much! Very clear and helpful.
Thank you so much 😊
Stay connected and please share with others too 😊
I watched plenty of videos to learn this but I didn't find another famous channel this is helpful maybe because they thought I knew Spring Boot so they just explained the code but your video is completely beginner friendly thanks, mam.
Glad to know that it helped you 😊 Thanks for sharing the feedback.
Stay connected and please share with others too 😊
Very nice tutorial
Thank you! Stay connected and please share with others too
This is great tutoroal to get the basic understanding of Springboot REST
Thanks 😊
Stay connected and please share with others too 😊
Thanku so much for these tutorial, these are very beginner friendly.
Great video and clearly explained pin to pin for REST API. This video will help for beginners and also working professionals. Thanks
Thank you so much 😊
Stay connected and please share with others too.
Excellent video ! learned a lot related CRUD operations and such clear explanation!
Glad it was helpful!
Thank you so much 😊
Stay connected and please share with others too.
Too late to found this. But gave more hope and strength. Thank you, its awesome.
Thank you so much 😊
Stay connected and please share with others too.
Work Appreciated🙌
Thank you Madam for explaining very briefly and clearly. This video is the best for complete beginners and intermediate people.
Thank you so much 😊
Stay connected and please share with others too 😊
Thank you so much! Very clear and helpful
Most welcome 😊
Stay connected and please share with others too, thanks 😊
Excellent Content! The best video ever, learnt the concepts with much ease, Thankyou!!
Thank you so much 😊 Very happy to know that the tutorials are helping you 😊
Stay connected and share with others too 😊
Thank you thank you thank you.. I can't thank you enough for this video tutorial👨🏫📓
Hi Esha, thank you so much for creating this playlist. Could you please make a project using React & Springboot. It will be really helpfull. Thank you
Thanks a lot for making this video. It gives us brief clearity about CRUD operations😊
Glad you liked it 😊
Please stay connected and share with others too. Thanks 😊
Thank you so much for this brief and clear explanation
Thank you 😊
Please stay connected and share with others too.
awesome video madam ,make more videos🤩
Loved the clear explanation!!
Thanks you so much 😊
Stay connected and please share with others too 😊
Thank you so much Esha very good work explained everything very well without any confusion to the audience/viewers. You actually cleared lot of stuff in this one video like why a particular thing is required over there why we have to write nor why it is performed over there particularly "Just explained like a teacher explaining to their primary class students ".
Thanks a lot for your efforts for this video
There are lot of people out their who need a instructors like you 💌
Thank you so much great words 🙏🏻 Really happy to know that it helped you 😊 ❤️
Stay connected and please share with others too 😊
This has been the most understandable lecture I have watched for spring boot
Glad it helped.
Please stay connected and share with others too. Thanks 😊
Awesome tutorial. loved it!!
Thank you so much 😊❤️
Please stay connected and share with others too.
Very good
Thanks 😊
Thank you for the excellent videos
Glad you liked it 😊 Thanks a lot ❤️❤️
Please stay connected and share with others too 😊
It was absolutely perfect.
Thank you 😊
Stay connected and please share with others too 😊
thank you for providing valuable information madam ...
Thanks a lot 😊
Note that if you're using Spring Boot 3 and above with this tutorial, the 'javax' namespace should be replaced by 'jakarta'.
Amazing mam!! thank you so much
Most welcome 😊
Please share with others too
Great tutorial!
Thank you so much.
Please share channel details with others too 😊
I like the videos very knowledgeable
Glad you like them!
Please share with others too
thank you mam for improving my concept.
Glad it helped you ❤️
Please stay connected and share with others too. Thank you 😊
Very good lecture. For me, when using Spring Boot version 3 some imports (such as javax.persistence.Entity) need to be changed to jakarta.persistence.Entity
Awesome tutorial
Thank you so much 😊
Stay connected and please share with others too.
Nice Explanation ..
Thanks 😊
Stay connected and please share with others too 😊
thank you very much this is very good
Welcome 😊
Stay connected and please share with others too. Thanks 😊
more than great👏👏
Thank you so much 😊❤️
Please stay connected and share with others too.
simple lectures .
Mam am facing issue i cannot post the vendor details in the post man throwing 404 error method not allowed, tried everything like component scan and port changing and path variable checking nothing works please guide me.
It's so perfect
Thank you so much 😊
Stay connected and please share with others too 😊
love you ma'am. great video
Thanks a lot 😊
Please share with others too
Ma'am please make a video for demo of installing db in docker and accessing workbench there. Thank you for this awesome content :)
Thanku ma'am
Welcome 😊
@@ThinkConstructive ma'am please upload java 8 concepts also thanku..
Sure, I will upload shortly.
you my lady did a great job i hope you keep making videos
Thank you so much 😊 Yes, I will continue making more videos.
Stay connected and please share with others too. Thanks 😊
thanks your explanation of concepts is very good
Most welcome 😊
Stay connected and please share with others too, thanks 😊
@@ThinkConstructive can you give me some advice further how can I create a client to access this rest api
thank you mam
Most welcome 😊
Please share with others too
excellent
Thank you so much..
Stay connected and share with others too 😊
Maam, I have a small doubt that *Spring-data-jpa* will support us to connect with MySQL DB, then why again we need to add MySQL dependency again, if am wrong pls correct me..!
Mam, how did you create 'getall' and 'getById' in cloudvendorApi-collection? I've tried several times but have only been able to see 'get'
Hi Mam, I watched your spring boot playlist and found your explanations very clear.
I have a question about the cloudvendorRespository and the cloudvendor model class. Should I create a repository for each model class, or can I extend multiple model classes within a single repository?
I wish I could subscribe a million times
Millions of thanks to you ❤️ ❤️. It is very motivating to see such amazing comment.
Stay connected and share with others too 😊
I did exactly the same, the application is running, but i cant see the table in the mysql workbench. Any solution for this?
Hi mam i am getting this error “ Missing artifact com.mysql:mysql-connector-java-jjar:8.0. “ while creating Rest Api in above way. I have added dependency in pom. Xml as well. how to resolve this
Hi Mam i like your explanation it's very clean and clear , Cloud you please make a video on Load balancer client side as well as server side and one video on messaging systems like Kafka and RabbitMQ
Sure, will plan it. Happy to know that my sessions are helping you 😊
Stay connected and please share with others too 😊
I just have few questions 1) In the video the database table is generated automatically while in my case i have to create it manually and then it gets connected. although i am not using mysql workbench instead i am using mysql through xamp. 2) If i import the table in my sql and it has column names as userId, userName etc... and in spring boot model also i name them similarly userId, userName..but when the table is connected somehow it require the value as user_id..why is it so bcoz i have never defined user_id.
I am adding the data via Postman but it's giving Null values as output. Could you please help me to get it resolved
Thanks for great tutorial ,
I'm trying to create cab project while following you but it is giving internal server error. I have checked all service,repository,model etc.
rewatched video many time but i still same can you suggest someting.
Database mysql configurations remains same in EC2 instance as well?
Excellent videos. Can you please create a full java tutorial for absolute beginners.
Thank you 😊
Need to plan the same
Hi Itd be helpful if you taught what to do to connect to workbench
Excellent way of teaching madam. Thank you so much. I have done your BUILD JAVA REST API WITH SPRING BOOT too. Only problem I have is table hasn't been created but database got created. If you have any suggestion for solving this please!!! Thank you again.
I got the same problem, Did you find any solution for that?
Mam I've written an application having api and deployed that application in a server...now want to access that api in another application..pls give some demos for that.Also wanted to add swagger to my application.how can I do it?
Mam please bring complete series on spring boot .
Sure
Stay connected and please share with others too. Thanks 😊
Thanks for an in depth explanation ma'am, looking forward to more such videos on Java, and Spring Boot. Maybe you can make a video on deploying the application to cloud using Heroku/AWS ma'am.
Welcome 😊
Sure, I will upload more Java & Spring Boot videos shortly and will include deployment tutorial in my plan.
Can you please do one video on difference between Hibernate vs Spring Data JPA with an example of spring project.
Please do.
Madam, database connection through application.yaml was not establishing, hence i used application.properties file for database connection, then it happened.
Ma'am what is the main difference between repository layer and payload .what are the uses of these two.??
Hi mam I am created tha project step step watching this but in Postman it comes 404 error whatever simple project I create it comes same error 404
😊god bless you mam😊
So when I run all my http methods in postman after creating a vendor in the DB I get an error when I try to retrieve a vendor by ID. I get the error "No value present" but my getAllVendor method works just fine. Any idea what could be wrong?
All method works fine. If vendor is created successfully in DB, get() fetches it.
May be if something is getting missed, please refer code from Github - github.com/thinkconstructive/rest-api-spring-boot-demo/tree/master
🙏🙏
Dear Maam, it is a nice explanation, but one thing, why you made the methods of the interface ( CloudVendorService) as public? they are by default public and abstract. Please consider my point.
Great Tutorial.Need one help can you please post one tutorial for how to use Exception handling in RestAPI in spring boot.
Thank you so much 🙂 Stay connected.
Exception handling tutorial with Rest Api is available here -
Exception Handling in Spring Boot REST API Explained With Demonstration
th-cam.com/video/L2o485T70Do/w-d-xo.html
@@ThinkConstructive can you please explain all annotation in springboot with example please,
Very nice and excellent, mam i have a project i want your guidance please guide me.
you r d best ma'aamm!! thank you
Most welcome 😊
Hi
I am confused, You have not used @Autowired How object injected in Controller
Can you please explain
Please!
Hi,
As of Spring 4.3, it is no longer needed to specify an explicit injection annotation i.e. @Autowired in a single-constructor scenario. Since, example which I have taken has only one constructor, hence @Autowired is not required.
Hi mam, why we don't add @Autowired annotation in controller class
We can also autowire dao obj in service rather than constructor
Please make the video for the different relational mappings with spring boot
Sure
Mam,the program running successfully but table is not created automatically
Will you covered hibernate also?
Wonderful video. Your way of teaching is soooo good and everything was so organised and clear. But I was not able to connect to my sql. I dont know what happend. Is there anything else I need to do to connect to mysql ?
Thanks 😊
Please check mysql ip/ port /userid and password related info. Mysql should be up and running before starting the application and also please include below dialect just in case missing in application.properties / application.yaml -
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Please refer application.yaml from below link -
github.com/thinkconstructive/rest-api-spring-boot-demo/blob/master/src/main/resources/application.yaml
Hi Mam, When you have add spring-boot-starter-data-jpa "dependencies", But You should show step by step...
Clearly explained but how the data was persisted and retrieved while doing CRUD operations performed in this video ????
Can you please make video on like if rest client application is react side application. How the process will be?
Hi Madam, Instead of isEmpty() --> empty() != null is this correct,
bcas when I try to use isEmpty() getting error.
u can do like this-
@Override
public CloudVendor getCloudVendor(String cloudVendorId) {
// More Business Logic
//if(cloudVendorRepository.findById(cloudVendorId).get()!=null)
Optional cloudVendor = cloudVendorRepository.findById(cloudVendorId);
if(!cloudVendor.isPresent()) {
throw new CloudVendorNotFoundException("Requested Cloud Vendor does not exist");
}
return cloudVendorRepository.findById(cloudVendorId).get();
}
hey
when im trying to create[post] in postman it shows 500 internal sever error.
what should i do now?
im getting same error did get it resolved
Thanks this is a best video of Spring boot demo. By the way, I am wondering that in MySQL Workbench, how can you get the cloud_vendor? Am I supposed to run the MySql Script? If it is, may I have that script please? Thank you!
Hi I thought I have solved this question after fully watching the video. however, I found a new issue, ie. I tried to INSERT VALUE into the database instead of adding the data to the database with POST/PUT. When I check the cloud_vendor_info with SELECT it shows the correct result. When I trigger the POST to add new data, I found that the previous data I inserted into the database was missing. How did it happen? Thank you for your help!
Thanks for the tutorial m'am, but would you ever make a video, with this crud implemented, but with persisted data ?
I really need it and I'm not finding it anywhere
This tutorial has full CRUD implementation with data persisted to MySQL database. Please explain more what exactly you are looking for!
@@ThinkConstructive I noticed it now ! Thanks anyways, but I still have some doubts, what if I wanted a soft deletion instead of a normal delete, and an attribute 'CreationData' or something close ? Can't find anything.
I Already got the creationData, i only need a soft deletion, can you help me ?
Nice!
There is no direct API available for soft deletion. Following steps can be used for soft deletion -
1. Include one more attribute in the database and use this attribute as flag (indicator) for deleted or not and set its default value to false
2. for soft deleting the row, use update query and set this flag attribute to true.
3. query database with a condition where flag is false.