Spring Tutorial 07 - Injecting Objects

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ก.ค. 2024

ความคิดเห็น • 137

  • @priyarajan620
    @priyarajan620 6 ปีที่แล้ว +17

    He makes the concepts so clear. The other tutorials by him are also great.Thanks Koushik.

  • @elmonkeh
    @elmonkeh 9 ปีที่แล้ว +94

    You really show this keyboard who is the boss.

    • @Java.Brains
      @Java.Brains  9 ปีที่แล้ว +67

      elmonkeh I should let you know that the keyboard has learnt its lesson now.

    • @elmonkeh
      @elmonkeh 9 ปีที่แล้ว +17

      Java Brains So did i, litterally - nice and thorough thumbs up!

  • @anunarayanan7133
    @anunarayanan7133 11 ปีที่แล้ว +4

    Thanks a lot for creating these set of tutorials for the Spring technology. All of your tutorials are very comprehensive and up to the point. Just want to let you know that you are doing a great favor for all those who are looking for good tutorials.

  • @josephkelly3152
    @josephkelly3152 4 ปีที่แล้ว +12

    This is such an incredible series of tutorials, you're an amazing teacher!

  • @MrHasan96
    @MrHasan96 7 ปีที่แล้ว +5

    I have been looking for such understandable lessons two days, finally I've found them! Perfect explanation! God bless you!

  • @bugfacedog44
    @bugfacedog44 9 ปีที่แล้ว +41

    TIL: straight lines are just triangles in disguise!

  • @SANJEEVKUMARbit
    @SANJEEVKUMARbit 6 ปีที่แล้ว +1

    I see few people commenting about wrong coordinates of triangle. These are those people who are very negative in their life. You wanted to see the full video , this alone is a victory of this tutorial. best explained kaushik jee.

  • @noherczeg
    @noherczeg 11 ปีที่แล้ว

    Short story about me: been searching for days, red hundreds of topics, posts about DI without a real realization about it.
    This was the thing that made me finally realize why is this topic so important, and why should I use this. I now UNDERSTOOD this.
    Thank you!

  • @pixelhunter7913
    @pixelhunter7913 7 ปีที่แล้ว +4

    I like the whole series very much, great tutorial - Thank you!

  • @arminsmajlagic2907
    @arminsmajlagic2907 ปีที่แล้ว

    I can not believe that this is 11 years old but still useful today. Good job man.

  • @barbie222222221
    @barbie222222221 4 ปีที่แล้ว +1

    this series should be updated

  • @marcroberto4604
    @marcroberto4604 11 ปีที่แล้ว

    Thank you for these tutorials. They are very clear and understandable.

  • @MrPepenowak
    @MrPepenowak 11 ปีที่แล้ว

    Excellent tutorial. The best one I could find for newbies. Thanks a lot!

  • @Java.Brains
    @Java.Brains  13 ปีที่แล้ว +1

    @ketkisawantm Much more.
    1. Ability to change the implementation without changing the code that's using it. See my tutorial "Coding to interfaces" to understand this concept.
    2. Ability to handle lifecycle of the object - write pre and post methods, write Aspects using AOP,
    3. Testability - Say you have to test a code execution that results in 5 levels of objects calling another object's methods, you can easily substitute a test stub class anywhere in the chain, just by changing your XML.

  • @user-ke9xj2mh4f
    @user-ke9xj2mh4f 8 ปีที่แล้ว

    凄い!!!あなたは一番教師です!!どうもありがとう!!

  • @888taish
    @888taish 8 ปีที่แล้ว +1

    This tutorial is very helpful for learning spring framework!!

  • @rav8149
    @rav8149 10 ปีที่แล้ว

    I like the way you kept it very simple. Thanks!

  • @DennyKWay
    @DennyKWay 10 ปีที่แล้ว

    Really enjoying your tutorials. Very logical and interesting presentation of information.

  • @Manitravelz
    @Manitravelz 8 ปีที่แล้ว +1

    Really well explained, Awesome tutorial, Thanks alot

  • @SerbianGuitar1
    @SerbianGuitar1 7 ปีที่แล้ว

    Beanception. Nice tutorials, very understandable, thank you!

  • @philanthrophic
    @philanthrophic 10 ปีที่แล้ว

    Just add toString to the Point Object.
    Nice tutorial!!!
    Thanks

  • @pratiksahu8845
    @pratiksahu8845 6 ปีที่แล้ว

    what a teacher....Heads up!!!!!!!!!!!!!!! grt work sir

  • @inderkalra923
    @inderkalra923 3 ปีที่แล้ว

    Thanks a ton Kaushik. Your videos are always full of information in digestible chunks.
    On a lighter note though, the coordinates are for a straight line on X-axis ;) :p

  • @mrinalsharma4137
    @mrinalsharma4137 9 ปีที่แล้ว +1

    Excellent tutorial... Thanks :)

  • @architapatnaik8116
    @architapatnaik8116 8 ปีที่แล้ว

    super like..awesome videos on spring .Thank you.

  • @hackers277
    @hackers277 10 ปีที่แล้ว

    Thanks a lot for this tutorial .. I loved the way you put these .. I'm glad

  • @m07377
    @m07377 5 ปีที่แล้ว

    Three points in a row! Great tutorial anyway! cheers mate

  • @muraliop7658
    @muraliop7658 3 ปีที่แล้ว

    you are an amazing teacher

  • @AminHasan85
    @AminHasan85 9 ปีที่แล้ว +1

    Very useful example.

  • @bhupendramishra8685
    @bhupendramishra8685 7 ปีที่แล้ว +1

    great explanation nice concept

  • @sanjeevreddy3327
    @sanjeevreddy3327 6 ปีที่แล้ว

    Thank you so much, It's a good resource

  • @rajaravikirans5307
    @rajaravikirans5307 6 ปีที่แล้ว

    Nice explanation Koushik..

  • @NazeerBashaShaik
    @NazeerBashaShaik 11 ปีที่แล้ว

    Thnx man.. this tutorials are really help full

  • @blackowl7009
    @blackowl7009 9 ปีที่แล้ว

    good work, Thank you!

  • @NiteshSahaykolkata
    @NiteshSahaykolkata 12 ปีที่แล้ว

    Very helpful tutorial regarding injection of object ...good for beginners..

  • @natetolbert3671
    @natetolbert3671 5 ปีที่แล้ว +4

    Line triangle = (Line) new TriangularLine.straighten();
    (btw, I LOVE your tutorials!)

  • @TheGuroguro12
    @TheGuroguro12 7 ปีที่แล้ว

    Thank you very much.

  • @adarshverma3372
    @adarshverma3372 3 ปีที่แล้ว +1

    Thank you for all your efforts
    Koushik can you please make a course on the spring mvc as this course has also becomes outdated

  • @connections2190
    @connections2190 6 ปีที่แล้ว

    very clear explanation.

  • @worldofkhyati
    @worldofkhyati 8 ปีที่แล้ว +1

    Thank you......

  • @user-xz5dm5nr1z
    @user-xz5dm5nr1z 6 ปีที่แล้ว

    Thank you

  • @ksven711
    @ksven711 11 ปีที่แล้ว

    Thank you Koushik :)

  • @sachinadya
    @sachinadya 11 ปีที่แล้ว

    Hey Koushik, thanks a lot for your tutorial. just wanted to bring in to ur attention that instead of typing entire System.out.println(), u could as well type sysout (Ctrl+space) will write the entire line... (Just in case u require)

  • @amitkumarsing
    @amitkumarsing 9 ปีที่แล้ว

    God bless you sir :)

  • @santubudhe2
    @santubudhe2 12 ปีที่แล้ว

    thank you

  • @willhdq
    @willhdq 7 ปีที่แล้ว

    I've been following your tutorial. Well done. Just to remind you to work out coordinates of an actual triangle before putting values on (0,0) (-20,0) (0,20) - the last two must have x and then subsequently, y changed, but not together. I know it's not important, they just served as data, but that's something should be noted.

  • @fokerfakerfuker
    @fokerfakerfuker 3 ปีที่แล้ว

    FYI your coordinates give u a straight line

  • @arpitsharma4944
    @arpitsharma4944 4 ปีที่แล้ว

    hats off sir ...

  • @vadymmorozov6956
    @vadymmorozov6956 10 ปีที่แล้ว

    Great!!!!!

  • @olegalekseev8053
    @olegalekseev8053 9 ปีที่แล้ว +19

    Cool, but in example we have three points on one line - it is not a triangle

  • @prakashvk2473
    @prakashvk2473 2 ปีที่แล้ว

    Here we can add toString method in Point class to save our efforts

  • @abhishekmishra14
    @abhishekmishra14 8 ปีที่แล้ว

    Great work. Do you have any tutorial for Spring Security and Angular JS

  • @pdoeoe25
    @pdoeoe25 11 ปีที่แล้ว

    Hi Koushik, I am really thankful to you , could learn spring concepts easily ..
    I have a question here
    in bean id triangle I am refering point object thrice .. as pointA , pointB , pointC as members of triangle object , here is point bean singleton ? if yes, then same object is returned for pointA, pointB, pointC??
    thanks in advance ..

  • @dineshbabu3227
    @dineshbabu3227 5 ปีที่แล้ว +3

    Great example.
    Instead of writing the sysout() thirce at 13:51 Should've implemented toString() in Point.class

    • @_first_touch_
      @_first_touch_ 3 ปีที่แล้ว +1

      It would be better, but a tutorial on spring should be as simple as possible. Their should be as less number of new concepts as possible so as to decrease concept dependency and that's why I love JavaBrains;

    • @dineshbabu3227
      @dineshbabu3227 3 ปีที่แล้ว

      If toString() is a new concept to someone, they should start with core java tutorials and not hurry into spring

  • @parthsalat3915
    @parthsalat3915 2 ปีที่แล้ว +1

    This is a 2011 video. You can hear him type on a old style mechanical keyboard... _(sobs)_

  • @UsernameNULL755
    @UsernameNULL755 10 ปีที่แล้ว +4

    hey, at 7:25 you should put the Y value as 20, not the X. you cant make a triangle if all the dots are on the same axis

    • @thevagabond85yt
      @thevagabond85yt 10 ปีที่แล้ว

      yes according to what he earlier planed. but that hardly matters as the implementation of draw() is too dull.

  • @subbu5b0
    @subbu5b0 6 ปีที่แล้ว

    Hi Koushik,
    Howmany Point objects does spring container creats.By default every bean is Singleton in spring.will it create only one Point object or 3 Point objects?

  • @taoliu1680
    @taoliu1680 8 ปีที่แล้ว

    Nice!!!

  • @koolstrings
    @koolstrings 11 ปีที่แล้ว +1

    Excellent info. btw..(0,0) (-20,0) (20,0) is a straight line :)

  • @gagzpics
    @gagzpics 7 ปีที่แล้ว +8

    the pointc should be 0,20 ..
    otherwise all points coming in a straight line and not forming a triangle.. just thought to let you know.. ☺

  • @AjayKumar-js1dy
    @AjayKumar-js1dy 7 ปีที่แล้ว

    You should make videos on Annotation based Spring

  • @MukulTripathi
    @MukulTripathi 13 ปีที่แล้ว +1

    Great tutorial, just one comment that at 7:09 when you were initializing the point3 object in the xml configuration, x should have been 0 and y should have been 20. Its not technical comment but just wanted to let you know. :) Great work Koushik!

  • @sureshonline11
    @sureshonline11 12 ปีที่แล้ว

    Thanks .. Nice video ..:)

  • @varun513
    @varun513 11 ปีที่แล้ว

    Ur Awsome............

  • @Lufase1
    @Lufase1 11 ปีที่แล้ว

    you can define a toString() method in Point:
    @Override
    public String toString() {
    return "[" + x + ", " + y + "]";
    }
    and then in the draw() method:
    System.out.println("Drawing triangle: " + pointA + ", " + pointB + ", " + pointC);

  • @Anandpasunoori
    @Anandpasunoori 8 ปีที่แล้ว

    did you check in these projects? any where?

  • @taruchitgoyal3735
    @taruchitgoyal3735 6 ปีที่แล้ว

    Hello,
    I tried with two coordinates, and it worked fine. Then, I tried entering third coordinate to see if it works for differnt number of values, but it failed. I have added the code below.
    Triangle.java
    package javabrains;
    public class Triangle {
    public String type;
    private Point pointA;
    private Point pointB;
    private Point pointC;
    private Point pointD;
    public Point getPointD() {
    return pointD;
    }
    public void setPointD(Point pointD) {
    this.pointD = pointD;
    }
    public Point getPointA() {
    return pointA;
    }
    public void setPointA(Point pointA) {
    this.pointA = pointA;
    }
    public Point getPointB() {
    return pointB;
    }
    public void setPointB(Point pointB) {
    this.pointB = pointB;
    }
    public Point getPointC() {
    return pointC;
    }
    public void setPointC(Point pointC) {
    this.pointC = pointC;
    }
    public String getType() {
    return type;
    }
    public void setType(String type) {
    this.type = type;
    }
    public void draw(){
    System.out.println("Draw "+getType()+" Triangle");
    System.out.println("PointA = "+getPointA().getX()+","+getPointA().getY());
    System.out.println("PointB = "+getPointB().getX()+","+getPointB().getY());
    System.out.println("PointC = "+getPointC().getX()+","+getPointC().getY());
    System.out.println("PointD = "+getPointD().getX()+","+getPointD().getY()+","+getPointD().getZ());
    }
    }
    spring.xml












    Point.java
    package javabrains;
    public class Point {
    private int x;
    private int y;
    private int z;
    public int getZ() {
    return z;
    }
    public void setZ(int z) {
    this.z = z;
    }
    public int getX() {
    return x;
    }
    public void setX(int x) {
    this.x = x;
    }
    public int getY() {
    return y;
    }
    public void setY(int y) {
    this.y = y;
    }
    }
    Please help.

  • @khaninkit
    @khaninkit 8 ปีที่แล้ว

    Nice!: Show us what is the limitation in spring.

  • @NeerajKumar-zo6bh
    @NeerajKumar-zo6bh 5 ปีที่แล้ว

    Sir i have questions How can we call getpoints method in draw...class directly its shud be called om the object of Trianlge coz those getter are inside the triangle plz rply asap!!! Thank-you

  • @mdpervej9052
    @mdpervej9052 4 ปีที่แล้ว

    what if i want the values to set dynamically

  • @efrenparra4549
    @efrenparra4549 11 ปีที่แล้ว

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: Cannot resolve reference to bean 'zeroPoint' while setting bean property 'pointA'; nested exception is org.springframework.beans.factory.BeanCreationException

  • @portilloza
    @portilloza 12 ปีที่แล้ว

    11:48 so cool

  • @naveengs2001
    @naveengs2001 6 ปีที่แล้ว

    Please add updated Spring concepts i.e feasible for 2k18

  • @miklosaszriev4821
    @miklosaszriev4821 11 ปีที่แล้ว

    You could have used autoWire="byName" in the Triangle bean config and cofigure the points to have the names of the point setters...

  • @srinicnu5283
    @srinicnu5283 2 ปีที่แล้ว +1

    I am a bit confused could i have the source code

  • @srivatsankannan8239
    @srivatsankannan8239 11 ปีที่แล้ว

    Hi I am getting the below error can some one tell me on what step i went wrong,
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'triangle' defined in class path resource [spring.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.srivatsan.spring.sample.Point' to required type 'java.awt.Point' for property 'pointA';

  • @FedJimSmith
    @FedJimSmith 11 ปีที่แล้ว

    Very nice there chief, very clear explanations and very well verse on your stuff.
    But I think you need a new keyboard.

  • @drcl7429
    @drcl7429 2 ปีที่แล้ว

    Understanding everything but not yet seeing the point of it. Seems more complicated than doing DI myself.

  • @jorgeviana1826
    @jorgeviana1826 10 ปีที่แล้ว

    So, we don't use the new keyword in our main method to create the Triangle, but instead we use a xml file that creates all the dependencies in a more verbose and ugly way. It seems that we are programing OO in a xml format. I expect things to get better and I hope that the complaint I have it's just a consequence of your fine qualities as a teacher, teaching first the basics and increasing complexity very slowly.

  • @hanabanana7774
    @hanabanana7774 3 ปีที่แล้ว

    ref 속성을 이용한 objects injection

  • @Kamikater2
    @Kamikater2 11 ปีที่แล้ว

    you need to paste in the "nested exception" part, there it says what couldnt be created.
    As far as it is readable, your PointA can't be created, but for why you need to post more of the stacktrace (the last part: 'nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [test.Point]: Constructor threw exception; nested exception is java.lang.NumberFormatException: For input string: "" ' is enough)

  • @bbugarschi
    @bbugarschi 13 ปีที่แล้ว

    @ketkisawantm look at how much code you got there.... what if you want to make 20 triangles with the same thing set.... how much code then??

  • @KnightInArmour10
    @KnightInArmour10 11 ปีที่แล้ว

    You are God. I worship you.

  • @stephenbrooks1898
    @stephenbrooks1898 7 ปีที่แล้ว

    This not will be triangle, but only a line.

  • @georgezhu1573
    @georgezhu1573 7 ปีที่แล้ว +4

    "You can go as deep as you want!" ---- Java Brains

    • @avdhesh2010
      @avdhesh2010 7 ปีที่แล้ว

      and Spring will make sure everyone is satisfied ;)

  • @geek.with.a.camera
    @geek.with.a.camera 3 ปีที่แล้ว

    Bean XML has all the hardcoded static values. I don't see any practical use of it. It's going to create the same triangle every time it is run.

    • @shaziasamreen8584
      @shaziasamreen8584 3 ปีที่แล้ว

      Yeah I too thought the same.Did you get the use of doing it?

  • @MOHITRATNESH
    @MOHITRATNESH 6 ปีที่แล้ว +5

    (0,0);(-20,0);(20,0) is a straight line not a triangle :P

  • @SukhrajMohammad
    @SukhrajMohammad 4 ปีที่แล้ว

    Anyway now instead of writing the code inside main function or class, you are writing same code in XML file, I am not Getting what is the exact benefits of such coding,we can achieve the same using Factory pattern, here it seems we just removing direct dependency to indirect dependency

  • @MrJonnis13
    @MrJonnis13 7 ปีที่แล้ว

    Great course as always.
    I wanted to ask how this example with the initialized properties of the Point objects could be if I wanted to use @ComponentScan and @AutoWired approach instead of having this verbose xml configuration.
    Can anyone help me on that ?

    • @Java.Brains
      @Java.Brains  7 ปีที่แล้ว +1

      One option is to use the @Value annotation to pull in values from property files. docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Value.html

    • @MrJonnis13
      @MrJonnis13 7 ปีที่แล้ว

      Thank you very much Sir for the answer. A bigger
      "thank you" though for all your effort and quality you bring with all your courses.

  • @efrenparra4549
    @efrenparra4549 11 ปีที่แล้ว

    any solution for this?

  • @alin2730
    @alin2730 10 ปีที่แล้ว +3

    What kind of triangle is that? 3 lines overlapping?

    • @BikasKatwalK
      @BikasKatwalK 9 ปีที่แล้ว

      :D right angled triangle not overlapping

    • @pramod2665
      @pramod2665 7 ปีที่แล้ว

      No actuallly when he explains with rough points ,that time he said right angled triangle. when he did practically, that time he selects wrong ponts. now its overlapping

    • @gcpdev123
      @gcpdev123 6 ปีที่แล้ว +1

      yes, it's a straight line. but bhaavnao ko samjho yr. ;-)

  • @gterre
    @gterre 11 ปีที่แล้ว

    your spring.xml should be in the src directory.

  • @sasquatch19888
    @sasquatch19888 11 ปีที่แล้ว +1

    7:25 - You created a line :).

  • @revanth1235
    @revanth1235 7 ปีที่แล้ว +1

    I am getting an error at this line undefined type getX() and getY(). the code is below
    System.out.println("Point A =("+getPointA().getX()+","+getPointA().getY()+")");
    can you help me ?

    • @gajjalasandeep1973
      @gajjalasandeep1973 7 ปีที่แล้ว

      hello revanth1235, please check the code in spring.xml and also look over to the reference i.e., ref , creating beans for the as shown in video of zeropoint,point2,point3 and previously you have to create getters and setters in Point.java class ....it will work fine....

    • @Lostforface
      @Lostforface 7 ปีที่แล้ว

      For any1 who has the same issue. take a look at your Point class you probably have something like
      int x
      getX
      setX
      getY
      setY
      int y
      basically you need to put that int y in the beginning.

  • @SankethShetty
    @SankethShetty 5 ปีที่แล้ว

    0:54

  • @branthebrave
    @branthebrave 3 ปีที่แล้ว

    It's called the origin 😆

  • @CyganskiHaker
    @CyganskiHaker 12 ปีที่แล้ว

    @kblaszke it's a degenerated triangle :)

  • @Charlie_Adventures
    @Charlie_Adventures 2 ปีที่แล้ว

    Nice Tutorial! But your triangle is a line in fact from -20 to 20 ….

  • @MartinMarchev
    @MartinMarchev 11 ปีที่แล้ว

    I would say this is a good practice. Normally getters and setters do the very simple task of getting or setting the value of a field but there might be cases in which the developer wants to sanitize or escape the value of a property whenever someone is interested into it. Let's say you have some XML writer or something which is supposed to escape special characters of a field so if you use a getter, you are on the safe side. Getters and setters are a tool of encapsulation as well, they hide impl

  • @sftw009
    @sftw009 11 ปีที่แล้ว

    Great tutorial, but you are not drawing a triangle with those coordinates :)