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.
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.
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!
@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.
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
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)
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.
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 ..
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;
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?
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!
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);
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.
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
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
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';
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.
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)
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
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 ?
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
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
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 ?
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....
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.
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
He makes the concepts so clear. The other tutorials by him are also great.Thanks Koushik.
You really show this keyboard who is the boss.
elmonkeh I should let you know that the keyboard has learnt its lesson now.
Java Brains So did i, litterally - nice and thorough thumbs up!
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.
This is such an incredible series of tutorials, you're an amazing teacher!
I have been looking for such understandable lessons two days, finally I've found them! Perfect explanation! God bless you!
TIL: straight lines are just triangles in disguise!
was thinking the same lol
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.
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!
I like the whole series very much, great tutorial - Thank you!
I can not believe that this is 11 years old but still useful today. Good job man.
this series should be updated
Thank you for these tutorials. They are very clear and understandable.
Excellent tutorial. The best one I could find for newbies. Thanks a lot!
@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.
凄い!!!あなたは一番教師です!!どうもありがとう!!
This tutorial is very helpful for learning spring framework!!
I like the way you kept it very simple. Thanks!
Really enjoying your tutorials. Very logical and interesting presentation of information.
Really well explained, Awesome tutorial, Thanks alot
Beanception. Nice tutorials, very understandable, thank you!
Just add toString to the Point Object.
Nice tutorial!!!
Thanks
what a teacher....Heads up!!!!!!!!!!!!!!! grt work sir
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
Excellent tutorial... Thanks :)
super like..awesome videos on spring .Thank you.
Thanks a lot for this tutorial .. I loved the way you put these .. I'm glad
Three points in a row! Great tutorial anyway! cheers mate
you are an amazing teacher
Very useful example.
great explanation nice concept
Thank you so much, It's a good resource
Nice explanation Koushik..
Thnx man.. this tutorials are really help full
good work, Thank you!
Very helpful tutorial regarding injection of object ...good for beginners..
Line triangle = (Line) new TriangularLine.straighten();
(btw, I LOVE your tutorials!)
Thank you very much.
Thank you for all your efforts
Koushik can you please make a course on the spring mvc as this course has also becomes outdated
very clear explanation.
Thank you......
Thank you
Thank you Koushik :)
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)
God bless you sir :)
thank you
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.
FYI your coordinates give u a straight line
hats off sir ...
Great!!!!!
Cool, but in example we have three points on one line - it is not a triangle
Here we can add toString method in Point class to save our efforts
Great work. Do you have any tutorial for Spring Security and Angular JS
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 ..
Great example.
Instead of writing the sysout() thirce at 13:51 Should've implemented toString() in Point.class
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;
If toString() is a new concept to someone, they should start with core java tutorials and not hurry into spring
This is a 2011 video. You can hear him type on a old style mechanical keyboard... _(sobs)_
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
yes according to what he earlier planed. but that hardly matters as the implementation of draw() is too dull.
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?
Nice!!!
Excellent info. btw..(0,0) (-20,0) (20,0) is a straight line :)
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.. ☺
You should make videos on Annotation based Spring
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!
Thanks .. Nice video ..:)
Ur Awsome............
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);
did you check in these projects? any where?
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.
Nice!: Show us what is the limitation in spring.
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
what if i want the values to set dynamically
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
11:48 so cool
Please add updated Spring concepts i.e feasible for 2k18
You could have used autoWire="byName" in the Triangle bean config and cofigure the points to have the names of the point setters...
I am a bit confused could i have the source code
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';
Very nice there chief, very clear explanations and very well verse on your stuff.
But I think you need a new keyboard.
Understanding everything but not yet seeing the point of it. Seems more complicated than doing DI myself.
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.
ref 속성을 이용한 objects injection
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)
@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??
You are God. I worship you.
This not will be triangle, but only a line.
"You can go as deep as you want!" ---- Java Brains
and Spring will make sure everyone is satisfied ;)
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.
Yeah I too thought the same.Did you get the use of doing it?
(0,0);(-20,0);(20,0) is a straight line not a triangle :P
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
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 ?
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
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.
any solution for this?
What kind of triangle is that? 3 lines overlapping?
:D right angled triangle not overlapping
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
yes, it's a straight line. but bhaavnao ko samjho yr. ;-)
your spring.xml should be in the src directory.
7:25 - You created a line :).
yeah, X axis
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 ?
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....
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.
0:54
It's called the origin 😆
@kblaszke it's a degenerated triangle :)
Nice Tutorial! But your triangle is a line in fact from -20 to 20 ….
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
Great tutorial, but you are not drawing a triangle with those coordinates :)