I know that:
ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
loads context definition from an XML file located in the classpath, treating context definitions as classpath resources.
ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");
loads context definition from an XML file in the filesystem.
XmlWebApplicationContext
loads context definition from an XML file contained within a web application.
But, what does it exactly mean??
Thanks :)
ClassPathXmlApplicationContext will read files from your classpath. They must be in classes folder of your web application or in a jar in your lib folder. FileSystemXmlApplicationContext can access all your file system, for example c:/config/applicationContext.
Path is used define where the system can find the executables(.exe) files and classpath is used to specify the location .
Classpath is a parameter in the Java Virtual Machine or the Java compiler that specifies the location of user-defined classes and packages. The parameter may be set either on the command-line, or through an environment variable.
PATH is used by CMD prompt to find binary files. CLASSPATH is used by the compiler and JVM to find library files.
ClassPathXmlApplicationContext
will read files from your classpath. They must be in classes
folder of your web application or in a jar
in your lib
folder.
FileSystemXmlApplicationContext
can access all your file system, for example c:/config/applicationContext.xml
.
XmlWebApplicationContext
certainly can access to files contained in your web application, but this is not the most important thing. It implements WebApplicationContext and this means that it will detect ServletContextAware beans, register custom scopes (request, session, ...) among other things.
FileSystemXmlApplicationContext- You need to provide complete full path of xml bean ClassPathXmlApplicationContext - In this case you DONOT need to set full path, as long as classpath is set
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With