Тёмный

How to read JSON data in Spring Boot and write to a database 

Dan Vega
Подписаться 58 тыс.
Просмотров 110 тыс.
50% 1

In this tutorial, you are going to learn how to read JSON data in a Spring Boot application and write it to a database. In the first part of this Spring Boot tutorial, you will create a new application using the Spring Initializr in IntelliJ. Next, you will learn how to read data from a JSON file and write it to an H2 database.
This presentation will cover:
✅ Create a new Spring Boot Project in IntelliJ IDEA
✅ Discuss what dependencies are needed for the project
✅ Read JSON data in a Spring Boot Application
✅ Take JSON data and insert it into a database
🔗Resources & Links mentioned in this video:
Source Code: github.com/danvega/spring-boo...
Spring Boot Introduction Course: www.udemy.com/course/spring-b...
👋🏻Connect with me:
Website: www.danvega.dev
Twitter: / therealdanvega
Github: github.com/danvega
Instagram: / thedanvega
LinkedIn: / danvega
Coffee & Code: www.danvega/dev/newsletter
SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

Опубликовано:

 

23 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 72   
@tahooramirbeigi1431
@tahooramirbeigi1431 2 месяца назад
I've been having CI/CD failures due to the json loading issues and with your solution now my project is deployed. Thanks a lot.
@Laharnaman
@Laharnaman 5 лет назад
Hey Dan! Yet another bulls-eye. Right on target for the kind of thing developers have to do on a regular basis. This kind of use-case / cook-book approach is super useful. You might already have this but would be good to see this exact scenario in a modern unit-testing framework like RestAssured -- or whatever you see as trending in the unit-testing world.
@marcodebernardi1463
@marcodebernardi1463 Год назад
simply the best! easy to follow, easy to understand, and easy to implement. 11/10
@user-kn8rl8rc8y
@user-kn8rl8rc8y 7 лет назад
Thanks a lot, you very good speaker. Good luck.
@anulekshmi6466
@anulekshmi6466 Год назад
Worked like a charm. Thank you!
@sujashade3106
@sujashade3106 Год назад
Great tutorial. Main application starts at 15:31
@Moewie
@Moewie 3 года назад
Like your vids! here it seems a bit more like a listing what to do, In your other videos you point out why you do sth more often, which is great. keep on going, damn good stuff.
@kabir_pathak
@kabir_pathak 4 года назад
Nice tutorial! Hey Dan, can you please do a tutorial on how to create a custom json deserializer in a Spring Boot project!? Thanks.
@quegrandiaparalaciencia8769
@quegrandiaparalaciencia8769 6 лет назад
Amazing, keep it up!
@codemixwithmasha3245
@codemixwithmasha3245 5 лет назад
if anyone has error with save List method, change it to saveAll
@satyateja5719
@satyateja5719 4 года назад
Iterable save(List users) getting error at *List
@gizlikalsn9262
@gizlikalsn9262 4 года назад
if we don't have any id what can we do in public interface UserRepository extends CrudRepository{ }
@saddamviera2596
@saddamviera2596 2 года назад
@@gizlikalsn9262 you can add id in the domain
@tomaszmachaj6485
@tomaszmachaj6485 Год назад
Thanks! This is what i was looking for among these comments.
@MrFernatico
@MrFernatico 2 месяца назад
Great!!!!! tks...
@swedhaselvaraj419
@swedhaselvaraj419 5 лет назад
hi...could you tell me how to convert csv to json and insert that jason file into couchdb using springboot
@Zak-uk8zx
@Zak-uk8zx 6 лет назад
Thanks, am loving your Udemy classes. well deserved 5-star rates
@khalidtrevor9449
@khalidtrevor9449 3 года назад
you probably dont care but if you're stoned like me during the covid times then you can stream all the new movies on InstaFlixxer. Have been binge watching with my girlfriend for the last days :)
@denverty9078
@denverty9078 3 года назад
@Khalid Trevor Yup, I've been watching on InstaFlixxer for years myself =)
@eimaisklhros
@eimaisklhros 5 лет назад
hi Dan great job. This was a simple Json from a file. But I want to consume an open weather API which gives you a key. How should I manage the key? where do I store it etc? simple storing, no need for security concepts yet. thank you.
@YashThakkar1611
@YashThakkar1611 5 лет назад
Hey, One question. Instead of Copy/Paste from jsonplaceholder can you fetch directly from URL and how?
@friday7510
@friday7510 5 лет назад
Thank u so much
@nanditabharadwaj4338
@nanditabharadwaj4338 Год назад
hello, thank you for the awesome tutorial and code, also can you please mention what datatype to use for a JSON array?
@kmacpher67
@kmacpher67 7 лет назад
Always good stuff. The @bean CommandLineRunner in Application Class was pretty cool, apparently that gets run after all the Spring beans are created and context is created. It basically does a shell .run(args), pretty cool way of doing a poor man's Spring Boot bootstrapping like Grails? Is that new or specific to Boot 1.5? Thanks.
@ssaliprosper1939
@ssaliprosper1939 4 года назад
i want to create another table in the database that saves json data from another different file but in the same application how do i do that. thanks for your tutorials
@petmik5022
@petmik5022 7 лет назад
best spring boot tuts
@DanVega
@DanVega 7 лет назад
Thank you!
@aniketyadav5024
@aniketyadav5024 4 года назад
Good job. Can you plese make a video on full business model for this mapping of json in database with service and repository interfaces
@abhichunchu3153
@abhichunchu3153 5 лет назад
How to read json data and perform Mathematical Operations ( Addition, Multiplication, etc) to data and emit the results as new json data. Small example with basic operation would be really helpful to me. Thank you
@dheerajscorefitness6981
@dheerajscorefitness6981 3 года назад
Hi, thanks for the video, very helpful, How to read json data using jpa ?
@shivamkumar001
@shivamkumar001 4 года назад
definitely helpful sire
@DanVega
@DanVega 4 года назад
Thank you ☺️
@sumant2000
@sumant2000 5 лет назад
what is the email addresses of users are many and it is array of email addresses. then what code change is needed here ?
@Rafal1992Rafa
@Rafal1992Rafa 5 лет назад
HELP! How can we do it with @OneToOne and @JoinColumn annotations?
@tipsyyoyo
@tipsyyoyo 4 года назад
how to update nested JSON data and write it to DB based on conditions?
@thee_wandering_monk16
@thee_wandering_monk16 3 года назад
hey i followed all steps but it still throws this error= "Unable to save users: Unrecognized field "id" (class com.example.demo.domain.User) even after i brought the right one "javaxpersistence"
@DVBLEX
@DVBLEX 3 года назад
how can i put object like this JSONObject object = new JSONObject(response.body()); to MySQL table with field text at Spring ?
@BoCUIcupidcb
@BoCUIcupidcb 3 года назад
HI, great video. A question, I want to improve the process which check the duplication before insert into db. Do you have some ideas ? Thanks.
@DanVega
@DanVega 3 года назад
You could use the unique constraint on the column annotation @Email @Column(unique = true) private String email;
@shubhamnavghare1937
@shubhamnavghare1937 3 года назад
how to store when we have dynamic data in json column?
@kirwakelvinkering3122
@kirwakelvinkering3122 Год назад
What of the case when the nested Json comes from the client app ? And am supposed to bind it to a java class using @RequestBody annotation ?
@DanVega
@DanVega Год назад
I'm not sure I follow. Can you give me an example of what you're trying to do?
@mohammadimteyazulhaque5603
@mohammadimteyazulhaque5603 5 лет назад
Thanks and good example can i have source code of this video
@khaledsharie112
@khaledsharie112 4 года назад
And how do I do this if my Json file has no Id?
@yogeshkumbhare2453
@yogeshkumbhare2453 5 лет назад
Hi Dan Tutorial was very awesome , but i want to know same json data bind to other third party vendor , they consume the json format , Can you please tell me How in spring boot and share the video to us. Thanks Dan for videos ....
@alfredozamorano371
@alfredozamorano371 5 месяцев назад
hola buenos dias una pregunta a mi me guarda pero me manda nullos por el id que esta en la clase user como lo resuelvo?
@ramakishan8685
@ramakishan8685 3 года назад
the same example can you make a video using spring batch
@pritamdhotre1780
@pritamdhotre1780 4 года назад
I got an error "Unable to save users:unrecognized field I'd (class com.therealdanvega.domain.user), not mark as ignorable". What I do for remove error
@sudhirkashyap7648
@sudhirkashyap7648 4 года назад
remove lombok annotations and use getter and setter
@pankajmalvi6761
@pankajmalvi6761 2 года назад
how to handle in case of json coming from frontend
@eleftheriosfadakis4385
@eleftheriosfadakis4385 5 лет назад
Hi Dan, thanks for the video but it seems I am facing an issue. When I run the app I get this "Unable to save users: Unrecognized field "id" (class com.therealdanvega.domain.User), not marked as ignorable (0 known properties: ]) at [Source: java.io.BufferedInputStream@6c3a6b69; line: 3, column: 12] (through reference chain: java.util.ArrayList[0]->com.therealdanvega.domain.User["id"])" I went to your git repository and downloaded your project and I still get the same message. I see in Users.java you import "com.fasterxml.jackson.annotation.JsonIgnoreProperties" Do you use it somehow and I missed it? Although both inputStream and typeReference are not null when the line "List users = mapper.readValue(inputStream, typeReference);" is executed it throws an exception. Thank you for your time.
@eleftheriosfadakis4385
@eleftheriosfadakis4385 5 лет назад
If I add in the mail class " mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);" I get the "Users saved!" message but then the "localhost:8080/users/list" returns: "[{},{},{},{},{},{},{},{},{},{}]"
@marktolj
@marktolj 4 года назад
@@eleftheriosfadakis4385 i get the same thing did you figure it out or still nothing?
@liakofan
@liakofan 4 года назад
@@marktolj I stopped working on it...
@marktolj
@marktolj 4 года назад
@@liakofan tnx anyway i managed to do it with Gson in the end this example did not work
@abineshsrs1974
@abineshsrs1974 6 месяцев назад
Hi bro, i couldn't get output😢 i don't know what is the error bt no error in my project
@snehakramesh8614
@snehakramesh8614 2 года назад
How to store list of objects to database using spring boot
@skseematabassum3129
@skseematabassum3129 Год назад
Hii Damn, great video but i have one doubt how i can get the user data
@DanVega
@DanVega Год назад
Can you please elaborate?
@soumendrasanyal513
@soumendrasanyal513 5 лет назад
Can you please help me to exchange some information between two servers
@DanVega
@DanVega 5 лет назад
Yes. What have you tried so far, what is the issue you're having?
@soumendrasanyal513
@soumendrasanyal513 5 лет назад
I need to make an framework where I need to accept some data from customer and i.e. receive information and make a normal response to that received signal
@DanVega
@DanVega 5 лет назад
@@soumendrasanyal513 Sounds like a REST API to me. Check out Spring Boot, easy way to stand up an API REST endpoint for your customer to hit and then you can send back a response.
@gizlikalsn9262
@gizlikalsn9262 4 года назад
I can't connect to localhost:8080 :(((
@ishaanniyazi7624
@ishaanniyazi7624 5 лет назад
Can you make a background white not able to see properly
@enricogiurin413
@enricogiurin413 5 лет назад
interesting, but it takes too long before get to the point, which is to read/write json in a DB
@razushikh4553
@razushikh4553 4 года назад
Is it possible without cmd ????
@DanVega
@DanVega 4 года назад
Is what possible?
@availkrishmytube
@availkrishmytube 3 года назад
I don’t understand why some folks record with such tiny fonts and a dark theme as in IntelliJ. It’s harder for eyes, which can easily be avoided with the light theme and slightly bigger fonts.
@DanVega
@DanVega 3 года назад
I agree, thanks for the feedback.
@baganaakh
@baganaakh 2 года назад
I got little deserialize Cannot deserialize value of type `java.time.LocalDate` from String "2021-08-04 09:39:53" :Failed to deserialize java.time.LocalDate: (java.time.format.DateTimeParseException)
@aryaprima2795
@aryaprima2795 2 года назад
TypeReference typeReference = new TypeReference(){}; Hello, why my List error and have command Type 'jdk.internal.org.objectweb.asm.TypeReference' does not have type parameters
Далее
They got a Golden Buzzer 🤣✨
00:46
Просмотров 13 млн
How to read JSON file in Java? ( Jackson Databind )
12:44
How To Debug React Apps Like A Senior Developer
21:07
How to do logging in Spring Boot - Brain Bytes
13:46
Просмотров 264 тыс.