12 Using a Bean to create RestTemplate instance - Spring Boot Microservices Level 1

12 Using a Bean to create RestTemplate instance - Spring Boot Microservices Level 1

Java Brains

5 лет назад

267,396 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@manivasuppalamarthi6948
@manivasuppalamarthi6948 - 06.07.2023 22:49

Very useful and very informative

Ответить
@omurduneto
@omurduneto - 14.01.2023 13:44

is the movie catalog service the api gateway?

Ответить
@aaajojoaaa
@aaajojoaaa - 09.12.2022 17:46

Consumer ->it is a void method and consuming an attribute t.ex public void method1(obj x ) {} , producer return an object or value t.ex public obj method2() { return new obj() }

Ответить
@ryoranggasumagusta3314
@ryoranggasumagusta3314 - 28.07.2022 18:02

Hello sir nice explanation, but i have question, if we create DI using @autowired without @beans on somewhere class, we keep got some value from @Autowired, so if we not use @Bean on some method, what @Autowired bring to property ? default inject all value? , and if we spesific some method using bean we just got the spesific value from that method ?

Thank you sir please help me

Ответить
@nayanankmahajan
@nayanankmahajan - 15.05.2022 05:37

Default is eager initialization for Bean. @Lazy used for lazy initialization. Lot of interview questions on Video 11 & 12 of this series. Watch it time and again till you fully understand RestTemplate and Bean initialization/scope etc.

Ответить
@andresdiaz2737
@andresdiaz2737 - 14.02.2022 19:01

To the best of my knowlage @Bean annotation could only be put away into the @Configuration class, which works as a bean container. What is the purpose of declaring a @Bean in the main class if the bean scan detector cannot get to it?

Ответить
@wondersmsvideos4743
@wondersmsvideos4743 - 17.01.2022 20:42

Is there are two method example getName and getAddress both return type is String and if we are going to make both as bean how does and autowired differentiate between those two methods

Ответить
@marcocabrerahernandez1646
@marcocabrerahernandez1646 - 25.11.2021 19:36

what is the best way to create the RestTemplate instance? . I've seen it using the RestTemplateBuilder

```
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.setReadTimeout(Duration.ofMillis()).build();
}
```

Ответить
@guruprasadkancharla5555
@guruprasadkancharla5555 - 20.11.2021 17:04

@Qualifier annotation is used to resolve the autowiring conflict, when there are multiple beans of same type

Ответить
@thisisceemolina
@thisisceemolina - 14.09.2021 04:23

Very clear explanation of the basics of @bean and its function <3 been searching for something like this for a while now..

Ответить
@TheWorldlife83
@TheWorldlife83 - 10.09.2021 21:25

Amazing explanation, cleared lot of concepts in just 7 minutes.

Ответить
@hyperborean72
@hyperborean72 - 06.09.2021 22:38

"By default, Spring creates all singleton beans eagerly at the startup/bootstrapping of the application context. The reason behind this is simple: to avoid and detect all possible errors immediately rather than at runtime"

Ответить
@JJ-ds2get-her
@JJ-ds2get-her - 03.09.2021 01:06

Q&A is the gem part of the vid.

Ответить
@danielgun
@danielgun - 31.08.2021 00:41

Usually the @Bean are defined in a @Configuration file. Not sure why that's not mentioned.

Ответить
@mayanktripathiurfrnd
@mayanktripathiurfrnd - 25.08.2021 05:52

I m not able to grasp wors u r saying.

Ответить
@shubhamchouksey9904
@shubhamchouksey9904 - 03.08.2021 08:41

I have used autowired and bean annotations several times but this video made me realise the true meaning of them

Ответить
@neb143
@neb143 - 14.07.2021 18:37

Hi Sir, I created RestTemplate template = new RestTemplate(); i printed in sysout(template) inside endpoint menthod. but still getting single object each request from diff browser also . Please reply sir.

Ответить
@raghavddps2
@raghavddps2 - 22.06.2021 17:02

Autowired is a consumer and Bean is a producer was one of the best explanations ever!

Ответить
@piyushkhanna30
@piyushkhanna30 - 10.06.2021 01:34

I have a doubt. I made Spring Boot Web Application without initializing class using @Bean (used @Service annotation above the class name) but used it in another class using @Autowired and it worked just fine. I am confused that if I didn't create its Bean then how does it get an instance.

Ответить
@zebra9389
@zebra9389 - 29.05.2021 08:28

I love how the students are asking questions and you are answering them. This allowed me as a virtual student to understand way better of the different concepts which many many Tutorials failed to do. They just teaches you how to use it without telling you why must you use them. Keep up the good work !

Ответить
@arushimathur7205
@arushimathur7205 - 17.05.2021 12:10

@JavaBrains , What is the need to create rest template bean? We could have autowired it directly.

Ответить
@rashmidhant3364
@rashmidhant3364 - 01.04.2021 00:46

I really love how you have kept and beautifully answered each and every queries the students have raised. While going through these videos a lot of these queries popped in my head and were cleared thanks to these Q/A.
Really Love all your videos and teaching style.

I would really like to support in any small way I can so I have
One question: Does "Joi"n provide same exclusive content(if there is any) as on the javabrains website. If yes would javabrains be a better option, sth like it directly goes to him or anything ?
Thank you very much.

Ответить
@AmNotLegend
@AmNotLegend - 24.03.2021 22:30

IOC create beans in an Eager way

Ответить
@markbdsouza
@markbdsouza - 16.03.2021 10:53

I love the fact that you've kept the questions. Some of these might seem silly to exp programmers but its the first thing that pops up when the topic is new. Love it.

Ответить
@robertkylethomas173
@robertkylethomas173 - 11.03.2021 11:39

@Bean and @Autowired explanation cleared up a lot of confusion for me

Ответить
@debapriyasen
@debapriyasen - 15.02.2021 23:15

You don't get error if you have two beans of the same type. And property name does matter, if autowire by type fails then it is autowired by bean name.

Ответить
@ryiamalattar5378
@ryiamalattar5378 - 07.12.2020 06:27

Great video that explains @Bean and @Autowired perfectly

Ответить
@sandeepnath9504
@sandeepnath9504 - 20.11.2020 00:47

I see a difference the browser did not even flash while refreshing after the changes it got quite fast

Ответить
@pramodrawate
@pramodrawate - 07.10.2020 18:19

The way in which you explain and especially the way you answer the doubts or resolve queries is something really unique, more precise, technically specific and yet easy to understand. You explain concepts in technical way but easy to grasp. Ex:- The way in which you explained that "@Bean is producer that says hey spring i have something which others might need. Whereas @Autowired is consumer which says i need RestTemplate". This is just one ex. Your videos are really outstanding. I have followed almost every tutorial of your's on Java , SpringBoot etc.

Amazing, full of learning, exceptionally outstanding.

Thanks for making the tutorial series. Keep it on.

Ответить
@madhug82
@madhug82 - 21.09.2020 05:00

brilliant tutorail. very simple to understand and to the point.. very neatly done. thanks!!

Ответить
@user-ir3jp5io1e
@user-ir3jp5io1e - 17.09.2020 00:31

thank you!

Ответить
@sudhanshusharma9159
@sudhanshusharma9159 - 16.09.2020 16:39

default is eager initialization.

Ответить
@bhaskarcmd
@bhaskarcmd - 25.08.2020 19:13

the below peace of code give compile time error

Ответить
@bhaskarcmd
@bhaskarcmd - 25.08.2020 19:11

how to implement it in java 12

Ответить
@himanshuchugh4257
@himanshuchugh4257 - 19.08.2020 19:04

When we make object of a class like this: a object = new a(); , at the time of execution of this code the object will be created every time the code is executed, but when we use @Bean annotation and make a function which returns an object of a class, and use @Autowired to access get the object, then the object will only be created once(when the program is run) and on multiple execution of same code, new object will not be created but the same which was created in the starting will be used.
IS THIS RIGHT UNDERSTANDING ???

Ответить
@mrAshwin06
@mrAshwin06 - 21.07.2020 21:55

Hi Kaushik, you made my day, I love this playlist. I have become a member.
Thanks for the attendees for asking some basic spring questions. It was like a refresher to me.
I have one request - Please come with a similar course for Spring webflux with a small use case project. That would be really helpful. Thanks.

Ответить
@kompalpaliwal2377
@kompalpaliwal2377 - 20.06.2020 23:50

Love the explanation for Beans and Autowiring , makes it crystal clear !

Ответить
@mksmurff
@mksmurff - 19.06.2020 12:44

"Autowired is a consumer" thank you. That one line has earned you a sub. Great video and delivery

Ответить
@vijaykumarsubramani5813
@vijaykumarsubramani5813 - 08.06.2020 12:31

Awesome

Ответить
@indraalapati989
@indraalapati989 - 11.05.2020 21:20

How singleton RestTemplate works in multithreaded environment ? Thanks in advance.

Ответить
@kumaranc4621
@kumaranc4621 - 06.05.2020 18:17

is it possible to add design pattern other than singleton using @Bean annotation

Ответить
@sayedsohel6913
@sayedsohel6913 - 05.05.2020 22:35

great job

Ответить
@anandspirit
@anandspirit - 26.04.2020 10:42

It’s more of spring briefing than microservices. Waste of time.

Ответить
@atulbhoyar5761
@atulbhoyar5761 - 29.03.2020 15:05

What about the hard coded URL ? How can we use Service Discovery ?

Ответить
@addisumm
@addisumm - 09.01.2020 07:58

Answer for the question: "When does the bean factory create the bean?, @4':20",
By default spring creates beans EAGERLY at the startup, which is the Singleton way of creating bean. But we can configure the bean factory, in a way that beans are created on demand (LAZY). Though there're several ways to tell Spring ( the IoC container) to initialize a bean lazily, the @Lazy annotation is commonly used since spring v-3.0.

Ответить