This tutorial is great and definitely needs an update to an recent versions of Spring. I hope you will find time to make some soon. Thanks for your amazing work!
This video is still relevant because even if we don't use the old framework much, we need to understand the configuration and basic concepts in order to know the latest framework and how the latest framework bypasses all the tedious configuation.
I followed your tutorial and it worked the first time!! It does mention that XmlBeanFactory is deprecated. I have fixed it using this line: ApplicationContext factory= new ClassPathXmlApplicationContext("spring.xml"); instead of: BeanFactory factory = new XmlBeanFactory(new FileSystemResource("spring.xml")); Thanks for the great tutorial.
i got spring setup in eclipse, now i can give a high level description about dependence injection, need for bean factory and how spring is helping avoid dependence between classes. thank you very much.
Thank you very much for taking time and effort to put this wonderful and useful tutorial. It is very simple and easy to follow. Love your teaching skills!
The XmlBeanFactory is deprecated. The better alternative is using ClassPathXmlApplicationContext as follow: ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
_ApplicationContext_ uses *eager loading* whereas _BeanFactory_ used *lazy loading* . It includes all functionality of _BeanFactory_ and more. For most of the enterprise applications, _ApplicationContext_ is preferred. Use as below: ApplicationContext context=new ClassPathXmlApplicationContext("springs.xml");
My guess is that Spring is not able to find the class Triangle that you've mapped for bean name "triangle". Have you double-checked the package name, class name for typos?
If someone use maven for this project: 1. spring.xml need to be in folder res/main/resources and 2. in DrawingApp main metod should be like this: // BeanFactory factory = new ClassPathXmlApplicationContext("spring.xml"); //Triangle triangle = (Triangle) factory.getBean("triangle"); //triangle.drawn();
XmlBeanFactory is deprecated in the latest version but you could try it this way (Like in the next Tutorial 05 ): //Gets the resource ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml"); Triangle triangle = (Triangle) context.getBean("triangle"); triangle.draw(); //Closes the context ( (ClassPathXmlApplicationContext) context ).close();
I like your english, especially the gaps between the words... "we're doing a (pause) bean", "you get a (pause) Triangle)"... once again, thanks for the great tutorial.
If you're getting the below exceptions, do the following: 1. Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist Solution: Write the fully qualified name of the spring.xml file, e.g. ApplicationContext factory= new ClassPathXmlApplicationContext("\\org\\pallavi\\spring\\spring.xml"); 2. org.xml.sax.SAXParseException; Content is not allowed in trailing section. Solution: When you're copying the contents of ApplicationContext.xml from some other website, it copies some other invisible characters too. You should create it fresh without copy-pasting so that extra characters are not added to the XML. e.g. Since I am using spring 5.1.1, I replaced 2.0 with 5.1.1 and it worked for me! Hope it helps! :) Thank you
for BeanDefinitionStoreException, we would see in error description, something like, parsing XML document from file[location], for me i had to include 'src\\', we .......what I am trying to say is, we can always use the location to find the location of xml file in local disk, which can be used accordingly :)
The tutorial series is good but no matter how I think about it I still do not see any advantage in using Spring for creating objects. Can someone explain to me the advantage?
Hi, I created the spring.xml under the root as you have explained but it showed me a IOExceptoin saying it couldn't find the XML file. I copied it under the 'src' folder and it worked. Is there any reason behind it?
+chandra kanth I think because we use ClassPathXmlApplicationContent() instead, it doesn't allow pass FileSystemResource variable. The path of FileSystemResouce is /, but that of ClassPathXmlApplicationContent is /src/ +Java Brains is it correct?
Even I encountered with same exception java.io.FileNotFoundException. I copied xml file under 'src' folder,but still i am getting same Exception. i appreciate your help ...Thank You
@Koushks : I have a doubt. If the spring.xml file has say like 100 entries meaning 100 classes. Does that mean we need to remember the names of all those classes in case we have to create an object of a particular class in DrawingApp? (like for example we create triangle object).
I am learning Spring framework and videos are very helpful for me. In this video, you have used Factory pattern for creating objects and so you have a brand new object whenever you call getBean(id) api. Is there a way to return an already created object if the same id is passed again?
I'm not following what was accomplished. You moved the new Triangle() out of code and into a config to avoid a code dependency on Triangle(), but then used Triangle in the method anyway, to store the reference from getBean(). So the code is still dependent on on Triangle(). So you added a spring config file, third party library (spring framework), effectively moved a possible compile time error to a run time error, all to eliminate the "new" keyword?
+flgliderpilot Not just new. The idea is to have the class depend on an interface and not an implementation. Having moved the new out of the class and into config, we now have the flexibility to supply a new instance of any class that implements that interface.
+flgliderpilot I agree with you. As for Triangle object, to be fully independent of any concrete type, I guess you would better use Shape Class, and then call shape.draw(), that way your class wouldn't be dependent on any concrete class.
Hi, when I try to import org.springframework.beans.factory.xml.XmlBeanFactory, it says that XmlBeanFactory is deprecated. Using spring 4.2.0 Kindly resolve!
I have did exactly the same what is done in the tutorial except that i have ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( new String[] {"spring.xml"}); in place of XmlBeanFactory. But when i run the program its not printing anything on console..its completely blank. Please help me!
Finally got the answer, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console
as many others i'm getting the annoying arror msg: class path resource [spring.xml] cannot be opened because it does not exist while I did everything shown in the video. as the methods are deprecated in newest releases, I changed BeanFactory etc into : BeanDefinitionRegistry factory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); reader.loadBeanDefinitions(new ClassPathResource("spring.xml")); Triangle tri1 = (Triangle) ((DefaultListableBeanFactory) factory).getBean("tri1"); in the XML file, it seems that the standard has changed as well (since when i put DOCTYPE in it, eclipse immediately shows me multiple errors, while without DOCTYPE I'm not getting any error msg). instead of DOCTYPE I looked up official notes and implemented the following lines: but still not working. why my spring.xml does not exist ? can't understand. If anyone knows what's wrong I'll appreciate that tnx
possible solution. but actually after searching I found that if the xml is defined directly in the current package of the src folder then everything works fine. otherwise we need to put the xml into a special folder (as in the case of boot projects). I still can't figure out how could his project in the video works with that xml defined at project level...
koushik @javabrains You put the spring jars and the common logging utilities in a spring folder in the project by right clicking on the project, going to properties ..... and creating a user library. How about if instead of creating a new user library, we right just add the external jar libraries under the libraries tag, would everything still work. Also, yes I know that XmlBeanFactory is deprecated in favour of ApplicationContext, but shouldn't a deprecated tag still work?
Hi Kaushik, Thanks a lot for these wonderful tutorials, these are really helpful. I had one question, I see tutorial bundles which got most hits in utube are of urs. So it must be good :) and thats not only for one framework , starting from servlet to spring, hibernet and more I just wonder how many framework have you mastered ... Just one thing these tutorials are very very helpful. I am done with 2 of the framework , thanks to u Is there any tutorials which is in more depth , or with some assignments which u can suggest Thanks again mate
In Spring v 5.0, BeanFactory is deprecated. Use below alternative for BeanFactory: BeanDefinitionRegistry factory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory); reader.loadBeanDefinitions(new ClassPathResource("spring.xml")); Triangle triangle = (Triangle) ((DefaultListableBeanFactory) factory).getBean("triangle"); triangle.draw();
The dependencies can be found from here repo.spring.io/release/org/springframework/spring/ [Spring jar] => Select the approriate version commons.apache.org/proper/commons-logging/download_logging.cgi [Apache jars] => Inside zip/tar file
That was really great Java Brains Can you please add some comments with respect to changes in latest spring It would be helpful. I know the effort of uploading the new video, so comments would be really helpful. Thanks
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file . Can anyone help me resolve this error?
Error: Unable to initialize main class com.edureka.springbootdemo.DrawingApp Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext help me anyone
10:03 I really thought of having that question raised in my mind WhyTF are u doing so many things for just having an output which is "SAME AS EARLIER" "Kaan ulte haath se kyun pakdte ho jab wahi milne wala hai yaara? ^_^"
In that, it is asking to select from:- 1.Well formed Document,2.DTD Constrained Document,3.XML schema constrained document.Which one of them am i supposed to select?
In that, it is asking to select from:- 1.Well formed Document,2.DTD Constrained Document,3.XML schema constrained document.Which one of them am i supposed to select?
I've downloaded the newest version of spring -version 4.1.6. I tried the code that was suggested within the comments below as a solution to the deprecated XmlBeanFactory, and unfortunately, that code failed to execute. Would someone be able to explain how to do all the steps in this tutorial using the latest version?
Robyn Silber So I just did the same steps as told in the tutorial with 4.1.6 and it worked fine. I assume you are using Java 1.6 and above. What happens when you try to run the code? Is there a compile time problem?
tejeswi vallamkonda Did u include logging classes as shown by Java brains during library setup? If so, ensure that the libarary is part of your current classpath.
Pratik Shende Should be obvious if you read the error! :) It doesn't find the spring.xml file. Check the path, and make sure it matches what I do in the video.
Ohh.thanks for the rply sir.I resolved that problem.actually problem.was in XML doc tag..as m using spring 4.1.6 .so the XML pattern is different for that.now its working sir.your teaching is good sir.Thanks for uploading videos.
Robyn Silber yeah.why not?just search for the XML pattern releated to the version you are using then just copy the XML pattern into your .XML file.it will work.if you still won't get how to do that,send me your mail id..ill gonna send you the XML pattern.
If you are getting XmlBeanFactory is deprecated warning use this alternative code ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml"); BeanFactory factory = context;
use ApplicationContext to get beans like this ApplicationContext context = new ClassPathXmlApplicationContext('yourPathOfConfigFlie'); context.getbean("beanID");
people who are facing problems while using XmlBeanFactory can start using ClassPathXmlApplicationContext to initialize *bean.xml. I hope this will solve the problem also for more discussion go through : stackoverflow.com/questions/5231371/springs-xmlbeanfactory-is-deprecated#answer-9210939
I'm getting a "java.io.FileNotFoundException exception" for my file "spring.xml" ApplicationContext context= new ClassPathXmlApplicationContext("triangle.xml"); Triangle triangle = (Triangle) context.getBean("triangle"); triangle.draw();
For all new viewers, as xmlBeanFactory is deprecated use Application Context instead, explained in next video.
This tutorial is great and definitely needs an update to an recent versions of Spring. I hope you will find time to make some soon. Thanks for your amazing work!
This video is still relevant because even if we don't use the old framework much, we need to understand the configuration and basic concepts in order to know the latest framework and how the latest framework bypasses all the tedious configuation.
Seen all four as soon as they came out... waiting for more... Excellent tutorials!
This is simplest and clear example i saw to create bean using bean factory and its implementation classes. thanks
I followed your tutorial and it worked the first time!! It does mention that XmlBeanFactory is deprecated. I have fixed it using this line: ApplicationContext factory= new ClassPathXmlApplicationContext("spring.xml"); instead of: BeanFactory factory = new XmlBeanFactory(new FileSystemResource("spring.xml"));
Thanks for the great tutorial.
Glad I was able to help 9 years in the past! Good luck!
Please donot delete these tutorials!!
@roshansalvi81 Hope you've seen the other tutorials on my channel. I cover Spring annotations in considerable detail.
For the latest version of Spring, the Spring.xml should be under the src directory to get rid of the No bean available exception :)
If you're getting classnot found then
this is the right way in spring.xml
This will work
i got spring setup in eclipse, now i can give a high level description about dependence injection, need for bean factory and how spring is helping avoid dependence between classes. thank you very much.
If someone is getting problem with DTD xml format then they can try the XSD XMl format as shown below:
Thank you so much! This solved my problem!
When I used the ApplicationContext I also had to move the spring.xml file into the src folder in the project instead of the project folder.
Thank you very much for taking time and effort to put this wonderful and useful tutorial. It is very simple and easy to follow. Love your teaching skills!
The XmlBeanFactory is deprecated. The better alternative is using ClassPathXmlApplicationContext as follow:
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
I am trying this, but I keep getting "File does not exist" error for spring.xml
need to put the xml file under src folder
Thank you Ram, it got solved...
_ApplicationContext_ uses *eager loading* whereas _BeanFactory_ used *lazy loading* . It includes all functionality of _BeanFactory_ and more. For most of the enterprise applications, _ApplicationContext_ is preferred. Use as below:
ApplicationContext context=new ClassPathXmlApplicationContext("springs.xml");
@@ramkethireddy9445 Correct, it worked well.Thanks
My guess is that Spring is not able to find the class Triangle that you've mapped for bean name "triangle". Have you double-checked the package name, class name for typos?
thank you so much.i have learned lot of things from your videos.
If someone use maven for this project: 1. spring.xml need to be in folder res/main/resources and 2. in DrawingApp main metod should be like this:
// BeanFactory factory = new ClassPathXmlApplicationContext("spring.xml");
//Triangle triangle = (Triangle) factory.getBean("triangle");
//triangle.drawn();
instead of xml file we can use configuration class
Putting spring.xml in src folder will also work.
Thanks!
Great Educator. Your instructions are concise and very helpful.
Awewsome Koushik ! Thank you so much for sharing your knowledge
XmlBeanFactory is deprecated in the latest version but you could try it this way (Like in the next Tutorial 05 ):
//Gets the resource
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
Triangle triangle = (Triangle) context.getBean("triangle");
triangle.draw();
//Closes the context
( (ClassPathXmlApplicationContext) context ).close();
Use ClassPathXmlApplicationContext instead of XmlBeanFactory for new versions
I like your english, especially the gaps between the words... "we're doing a (pause) bean", "you get a (pause) Triangle)"... once again, thanks for the great tutorial.
XmlBeanFactory is deprecated . You videos are great but please update them.
I am going to write an exam about software architecture tomorrow - thx for your nice explanation.
Thank you so much! you lighten my life.
Very clean and clear tutorial. Awesome
In my case its depriccating the XmlBeanFactory
Nothing works. I am doing projects on all your work but unfortunately nothing works. Errors and Errors and Errors.
If you're getting the below exceptions, do the following:
1. Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
Solution: Write the fully qualified name of the spring.xml file, e.g. ApplicationContext factory= new ClassPathXmlApplicationContext("\\org\\pallavi\\spring\\spring.xml");
2. org.xml.sax.SAXParseException; Content is not allowed in trailing section.
Solution: When you're copying the contents of ApplicationContext.xml from some other website, it copies some other invisible characters too. You should create it fresh without copy-pasting so that extra characters are not added to the XML.
e.g.
Since I am using spring 5.1.1, I replaced 2.0 with 5.1.1 and it worked for me!
Hope it helps! :)
Thank you
for BeanDefinitionStoreException, we would see in error description, something like, parsing XML document from file[location], for me i had to include 'src\\', we .......what I am trying to say is, we can always use the location to find the location of xml file in local disk, which can be used accordingly :)
This really helped me! Thanks!
Guys, XMLBeanFactory is depricated.So, Use:
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
BeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(new FileSystemResource("Spring.xml"));
worked for me! thnks
Make sure there's no blank space after , otherwise big fat exception.
I'm getting a "XmlBeanDefinitionStoreException"
XmlBeanFactory is depreciated what does it means when we are import it it shows that msg
Loved this
Great tutorial, it would be better if the project is first created as Maven project though
The tutorial series is good but no matter how I think about it I still do not see any advantage in using Spring for creating objects.
Can someone explain to me the advantage?
Great tutorial, clear and precise. A quich question is can I use hibernate in a stand alone application?
why i am getting suppress warning annotations?
Error occurred during initialization of boot layer
java.lang.module.FindException: Module spring.beans not found, required by SpringDemo
"...why are we performing this circus act..." haha
Hi, I tried implementing the above program but it shows the error as "XmlBeanFactory is deprecated". Can you please tell me why it shows this?
Hi, I created the spring.xml under the root as you have explained but it showed me a IOExceptoin saying it couldn't find the XML file. I copied it under the 'src' folder and it worked. Is there any reason behind it?
+chandra kanth I think because we use ClassPathXmlApplicationContent() instead, it doesn't allow pass FileSystemResource variable. The path of FileSystemResouce is /, but that of ClassPathXmlApplicationContent is /src/ +Java Brains is it correct?
Can u elobarate more
Even I encountered with same exception java.io.FileNotFoundException. I copied xml file under 'src' folder,but still i am getting same Exception. i appreciate your help ...Thank You
A little tip: Ctr+Shift+O will do all your imports at once.
awesome tutorial!! thank you!!
@Koushks : I have a doubt. If the spring.xml file has say like 100 entries meaning 100 classes.
Does that mean we need to remember the names of all those classes in case we have to create an object of a particular class in DrawingApp? (like for example we create triangle object).
I am learning Spring framework and videos are very helpful for me. In this video, you have used Factory pattern for creating objects and so you have a brand new object whenever you call getBean(id) api. Is there a way to return an already created object if the same id is passed again?
I'm not following what was accomplished. You moved the new Triangle() out of code and into a config to avoid a code dependency on Triangle(), but then used Triangle in the method anyway, to store the reference from getBean(). So the code is still dependent on on Triangle(). So you added a spring config file, third party library (spring framework), effectively moved a possible compile time error to a run time error, all to eliminate the "new" keyword?
+flgliderpilot Not just new. The idea is to have the class depend on an interface and not an implementation. Having moved the new out of the class and into config, we now have the flexibility to supply a new instance of any class that implements that interface.
+flgliderpilot I agree with you. As for Triangle object, to be fully independent of any concrete type, I guess you would better use Shape Class, and then call shape.draw(), that way your class wouldn't be dependent on any concrete class.
Is this just for ECLIPSE? I do not see a BeanFactory in NetBeans.
i have added all the reqiured jar files, but still beanfactory interface and xmlbeanfactory classes are not getting resolved. sumone pls help
Hi, when I try to import org.springframework.beans.factory.xml.XmlBeanFactory, it says that XmlBeanFactory is deprecated. Using spring 4.2.0
Kindly resolve!
+Akeshwar Jha stackoverflow.com/questions/5231371/springs-xmlbeanfactory-is-deprecated#answer-9210939
I have did exactly the same what is done in the tutorial except that i have ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
new String[] {"spring.xml"});
in place of XmlBeanFactory. But when i run the program its not printing anything on console..its completely blank. Please help me!
Really excellent
Are there any other means of configuring the bean factory other than using XMLBeanFactory?...Just curious!
Very good explanation. But I was looking out for spring 3.0 examples with annotation.
Thanks a lot for making this tutorial!
i'm getting class not found exception for the program when i tried how to build it?
I can't import those spring factory library in my class.... I have added the spring factory jars as specified in the video... But diffrnt version
if someone is using the maven then add the spring.xml in the src/main/resources
can u pls tell how we can get those info level messages on the console? pls i'm struggling to get that since 6 months.
Finally got the answer, after almost a year. I needed to use the earlier version of springs; used 4.2.2 instead of 5.2.2. Now I can see the info logs in the console
Yes, in last version Spring 4 XmlBeanFactory is cross out.
I'm also using Netbeans IDE
Will you please update all the videos with the latest spring version?
Great example. thx
From where to get the code ?
Please give us the Doctype code!
Awesome
if we do factory.getBean("triangle",Triangle.class) i dont think we need to type cast it.
as many others i'm getting the annoying arror msg: class path resource [spring.xml] cannot be opened because it does not exist while I did everything shown in the video. as the methods are deprecated in newest releases, I changed BeanFactory etc into :
BeanDefinitionRegistry factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource("spring.xml"));
Triangle tri1 = (Triangle) ((DefaultListableBeanFactory) factory).getBean("tri1");
in the XML file, it seems that the standard has changed as well (since when i put DOCTYPE in it, eclipse immediately shows me multiple errors, while without DOCTYPE I'm not getting any error msg). instead of DOCTYPE I looked up official notes and implemented the following lines:
but still not working. why my spring.xml does not exist ? can't understand. If anyone knows what's wrong I'll appreciate that tnx
try to write full path to the spring.xml For example: /org/koushik/javabrains/Spring.xml in DrawingAppClass
possible solution. but actually after searching I found that if the xml is defined directly in the current package of the src folder then everything works fine. otherwise we need to put the xml into a special folder (as in the case of boot projects). I still can't figure out how could his project in the video works with that xml defined at project level...
Use this:
Since I am using spring 5.1.1, I replaced 2.0 with 5.1.1 and it worked for me!
Thanks!
@@pallavimanan4124 thanks mam now it works
xml document from class path resource is invalid.. :(
koushik @javabrains You put the spring jars and the common logging utilities in a spring folder in the project by right clicking on the project, going to properties ..... and creating a user library. How about if instead of creating a new user library, we right just add the external jar libraries under the libraries tag, would everything still work.
Also, yes I know that XmlBeanFactory is deprecated in favour of ApplicationContext, but shouldn't a deprecated tag still work?
In regards to the deprecated tag question, Yes it will work, I tried it for Spring v-3.2.0.
is this deprecated?
it was awesome learning this.
Hi Kaushik,
Thanks a lot for these wonderful tutorials, these are really helpful.
I had one question, I see tutorial bundles which got most hits in utube are of urs.
So it must be good :) and thats not only for one framework , starting from servlet to spring, hibernet and more
I just wonder how many framework have you mastered ...
Just one thing these tutorials are very very helpful.
I am done with 2 of the framework , thanks to u
Is there any tutorials which is in more depth , or with some assignments which u can suggest
Thanks again mate
Really good tutorial!
you work is with MVC?
thx
In Spring v 5.0, BeanFactory is deprecated. Use below alternative for BeanFactory:
BeanDefinitionRegistry factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource("spring.xml"));
Triangle triangle = (Triangle) ((DefaultListableBeanFactory) factory).getBean("triangle");
triangle.draw();
Why i am getting Calss not found exception error on the same code?
me too
The dependencies can be found from here
repo.spring.io/release/org/springframework/spring/ [Spring jar] => Select the approriate version
commons.apache.org/proper/commons-logging/download_logging.cgi [Apache jars] => Inside zip/tar file
That was really great Java Brains Can you please add some comments with respect to changes in latest spring It would be helpful.
I know the effort of uploading the new video, so comments would be really helpful.
Thanks
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file . Can anyone help me resolve this error?
Error: Unable to initialize main class com.edureka.springbootdemo.DrawingApp
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
help me anyone
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
Works.
Thank you very much.
10:03 I really thought of having that question raised in my mind
WhyTF are u doing so many things for just having an output which is "SAME AS EARLIER"
"Kaan ulte haath se kyun pakdte ho jab wahi milne wala hai yaara? ^_^"
thanks for the videos
where to put spring.xml in netbeans in my case it is not reconizing it
maybe it's late but... you have to put the spring.xml file in the /src folder
In that, it is asking to select from:- 1.Well formed Document,2.DTD Constrained Document,3.XML schema constrained document.Which one of them am i supposed to select?
In that, it is asking to select from:- 1.Well formed Document,2.DTD Constrained Document,3.XML schema constrained document.Which one of them am i supposed to select?
I've downloaded the newest version of spring -version 4.1.6. I tried the code that was suggested within the comments below as a solution to the deprecated XmlBeanFactory, and unfortunately, that code failed to execute. Would someone be able to explain how to do all the steps in this tutorial using the latest version?
Robyn Silber So I just did the same steps as told in the tutorial with 4.1.6 and it worked fine. I assume you are using Java 1.6 and above. What happens when you try to run the code? Is there a compile time problem?
Sudarshan Datta i have the same problem.
It shows NoClassDefFoundError: org/apache/commons/logging/LogFactory
tejeswi vallamkonda Did u include logging classes as shown by Java brains during library setup? If so, ensure that the libarary is part of your current classpath.
Sudarshan Datta Thanks you, I had the same problem, you helped me a lot. This logging class is commons-logging-x.x.jar
java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist ,sir am getting this error..help me in that
Pratik Shende Should be obvious if you read the error! :) It doesn't find the spring.xml file. Check the path, and make sure it matches what I do in the video.
Ohh.thanks for the rply sir.I resolved that problem.actually problem.was in XML doc tag..as m using spring 4.1.6 .so the XML pattern is different for that.now its working sir.your teaching is good sir.Thanks for uploading videos.
Pratik Shende Hi, would you mind providing a quick explanation and the code of the changes made using the latest version?
Robyn Silber yeah.why not?just search for the XML pattern releated to the version you are using then just copy the XML pattern into your .XML file.it will work.if you still won't get how to do that,send me your mail id..ill gonna send you the XML pattern.
Pratik Shende Could you post it here ?
If you are getting XmlBeanFactory is deprecated warning use this alternative code
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
BeanFactory factory = context;
Or you can use a
Triangle triangle = (Triangle) context.getBean("triangle"); // instead of factory.getBean("triangle")
nice tutorial Sir G
I dont have that spring folder in my java project, how you guys have that? fyi spring is already installed on my computer
How important is this 10 year old video if it is deprecated?
hey, does anyone know the difference between the id and the name of the bean?
很好
try this ClassPathXmlApplicationContext mContext=new ClassPathXmlApplicationContext("spring.xml")
those poor keyboard keys really took a beating :(
Can you give link for jars!
get a warning that the XMLBeanFactory has been deprecated
use ApplicationContext to get beans like this
ApplicationContext context = new ClassPathXmlApplicationContext('yourPathOfConfigFlie');
context.getbean("beanID");
people who are facing problems while using XmlBeanFactory can start using ClassPathXmlApplicationContext to initialize *bean.xml. I hope this will solve the problem also for more discussion go through : stackoverflow.com/questions/5231371/springs-xmlbeanfactory-is-deprecated#answer-9210939
I'm getting a "java.io.FileNotFoundException exception" for my file "spring.xml"
ApplicationContext context= new ClassPathXmlApplicationContext("triangle.xml");
Triangle triangle = (Triangle) context.getBean("triangle");
triangle.draw();