Spring MVC Http Interfaces - How to Create a Rest Client with almost no code!

  Рет қаралды 10,770

Dan Vega

Dan Vega

3 ай бұрын

In this tutorial you will learn how to use Http Interfaces in Spring MVC. In Spring Boot 3.2 Http Interfaces will use the new Rest Client allowing you take advantage of Http Interfaces without having to pull in any other dependencies.
🔗Resources & Links mentioned in this video:
Spring Academy: spring.academy/guides/http-in...
👋🏻Connect with me:
Website: www.danvega.dev
Twitter: / therealdanvega
Github: github.com/danvega
LinkedIn: / danvega
Newsletter: www.danvega.dev/newsletter
SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

Пікірлер: 37
@Salvvy
@Salvvy 3 ай бұрын
Fantastic introduction to Http Interfaces. Would love to see how this can interact with APIs with OAuth (if at all)
@mrcoder9401
@mrcoder9401 3 ай бұрын
+1, Would love to see how this can interact with APIs with OAuth
@arghyamitra3281
@arghyamitra3281 3 ай бұрын
Great 💯 love to see how to add interceptor ( eg: want to add a header ) nd error handling with it
@bibahbibah5108
@bibahbibah5108 24 күн бұрын
spring boot 3.2 has very nice futures. it's a remplacement of feign dependencies, i hope that we can do wht feign do (headers and interceptor )
@AdrianVrabie
@AdrianVrabie 3 ай бұрын
That's great for demos and MVPs. In RL you might need to put some specific headers in the calls, which can be path dependent :)
@AgrimRocks
@AgrimRocks 3 ай бұрын
If you are using ultimate edition, you can create new project using spring initializer from within the ide using File -> New Project -> Spring Initializer
@DanVega
@DanVega 3 ай бұрын
Thank you! I try to remember that not everyone is using IntelliJ ultimate edition and thats why i use start.spring.io
@oskar9136
@oskar9136 3 ай бұрын
Hi Dan!
@aravintht.k9276
@aravintht.k9276 3 ай бұрын
Hi Dan, Great video. Can we handle exceptions thrown from the other service using @ControllerAdvice like we normally do or it has any restrictions on that?
@cviniciusm
@cviniciusm 3 ай бұрын
I would like to suggest to show us an approach of using Polymorphism to create a common contract for UserRestClient and UserHttpClient because in practice we can use this approach to migrate from another/previous client to these new ones by just injecting the right client.
@richardbenes9
@richardbenes9 3 ай бұрын
Nice tutorial, thanks. What about handling non-200 return codes though?
@replicant777
@replicant777 3 ай бұрын
Hi Dan! Great video! Currently we are on spring boot 2 and use feign (incl some spring integrations like oauth2 or decoders) for creating rest clients to all apis where there are no public java client apis available. Works really great and we love the declarative style. What's the benefit of using this new spring way and will spring feign support be discontinued?
@andytael
@andytael 3 ай бұрын
Maybe a strange question, but doesn't Feign do this already (with Eureka discovery) and it is easy? Or am I missing something. Awesome video!
@manojdahiya9332
@manojdahiya9332 3 ай бұрын
Hi Dan, What do you think about using openfeign
@renatmirzoev2167
@renatmirzoev2167 3 ай бұрын
But what if I want to have some custom error handler for cases like Not Found? Or throw an exception?
@user-qv9rx9qn6u
@user-qv9rx9qn6u 3 ай бұрын
Hi Dan,I would like to ask how to use restclient to retry http requests upon failure, and whether spring-retry can be used.
@RicardoSilvaTripcall
@RicardoSilvaTripcall 3 ай бұрын
Another great tutorial Dan, congrats. Silly question, how to maintain the json field order in the response? They are all over the place here :)
@JamesStansell
@JamesStansell 3 ай бұрын
It's the http command sorting the fields. It has the --unsorted param to output the result with the fields in the order sent by the application.
@RicardoSilvaTripcall
@RicardoSilvaTripcall 3 ай бұрын
@@JamesStansell Thanks for the reply, --unsorted solved the problem, it was my first time using httpie.
@amjedallaya9688
@amjedallaya9688 3 ай бұрын
Thnx Dan, great video as usual, but can you please try to use dark mode for the videos... as a member of dracula developers community I really find it hard to follow the code with all these brightness 😅🤣
@JamesStansell
@JamesStansell 3 ай бұрын
Thanks Dan! I am really curious to know if the fields of the Geo class populated correctly :)
@manojdahiya9332
@manojdahiya9332 3 ай бұрын
@JamesStansell No, we need to use json property to set the data in Geo class field
@morkhoudia9
@morkhoudia9 3 ай бұрын
Hi Dan , it will be intéressed a tutorial to use web client calling the use api by iterating and populate to h2 and benching for reactive and a non reactive client...
@hassanrefaat572
@hassanrefaat572 3 ай бұрын
how about if i want to handle the exception which is maybe happen form the upstream service how could i do that?
@AndreTiconaRollano
@AndreTiconaRollano 2 күн бұрын
Hey Dan, is there a way to use HttpInterfaces and RestClient with Spring Cloud to point to service names instead of urls? I'd appreciate if you could point me to any documentation on this regard.
@user-vr1od8gk5d
@user-vr1od8gk5d 2 ай бұрын
how to modify request headers in this case (for example, with some bearer token )?
@DineshRN751
@DineshRN751 3 ай бұрын
Using this approach with webclient for a while now, and it kind of gets messy creating beans for each rest. Spring Boot should have some annotation or something to solve this.. Or a custom annotation to do this?
@brayanhernandezmora8619
@brayanhernandezmora8619 3 ай бұрын
Junior question it’s feing client good for doing this ?
@Razpirato
@Razpirato 3 ай бұрын
It be great if you could add retries.
@AleksandarT10
@AleksandarT10 3 ай бұрын
Hopefully the Spring team adds some kind of annotation on top of the interface so we dont have to do the boiler plate code in the future!
@maksimmuruev423
@maksimmuruev423 3 ай бұрын
Buy what will happen if gateway is not available.. or its return some specific JSON error? We are in network it has no 100% response guarantee.
@DanVega
@DanVega 2 ай бұрын
It's using the RestClient under the hood, you could implement something like retry...
@subba18
@subba18 2 ай бұрын
How HTTP Interface is different from Spring Cloud OpenFeign?
@scitechplusexplorer2484
@scitechplusexplorer2484 3 ай бұрын
Hi Dan! Nice video. Can you please make some fresh content related to Spring GraphQL, although u have made it, but still once again, but not just basics, some pretty advanced stuff!!
5 Common Mistakes Spring Developers Make
18:06
Dan Vega
Рет қаралды 15 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 106 МЛН
Java is slow and verbose (or so they say)
20:39
Dan Vega
Рет қаралды 9 М.
Spring Boot APIs Gateway in 20 Minutes
22:50
The IT Wizard
Рет қаралды 8 М.
Spring Tips: Spring Data JDBC
27:36
SpringDeveloper
Рет қаралды 17 М.
You might not need useEffect() ...
21:45
Academind
Рет қаралды 151 М.
Rest API - Best Practices - Design
15:50
High-Performance Programming
Рет қаралды 98 М.
10 Spring and Spring Boot Common Mistakes You Need To STOP
15:49
Amigoscode
Рет қаралды 141 М.
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 10 МЛН
WWDC 2024 Recap: Is Apple Intelligence Legit?
18:23
Marques Brownlee
Рет қаралды 6 МЛН
Cadiz smart lock official account unlocks the aesthetics of returning home
0:30
Secret Wireless charger 😱 #shorts
0:28
Mr DegrEE
Рет қаралды 1,7 МЛН
Купил этот ваш VR.
37:21
Ремонтяш
Рет қаралды 297 М.