类路径,文件系统之间有什么区别? [英] What is difference between class path , file system?
问题描述
我知道:
-
ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
从位于类路径中的XML文件中加载上下文定义,将上下文定义视为类路径资源.
loads context definition from an XML file located in the classpath, treating context definitions as classpath resources.
ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");
从文件系统中的XML文件加载上下文定义.
loads context definition from an XML file in the filesystem.
XmlWebApplicationContext
从Web应用程序中包含的XML文件中加载上下文定义.
loads context definition from an XML file contained within a web application.
但是,这到底是什么意思?
But, what does it exactly mean??
谢谢:)
推荐答案
-
ClassPathXmlApplicationContext
将从您的类路径读取文件.它们必须位于Web应用程序的classes
文件夹中,或者位于lib
文件夹中的jar
中.ClassPathXmlApplicationContext
will read files from your classpath. They must be inclasses
folder of your web application or in ajar
in yourlib
folder.FileSystemXmlApplicationContext
可以访问您的所有文件系统,例如c:/config/applicationContext.xml
.FileSystemXmlApplicationContext
can access all your file system, for examplec:/config/applicationContext.xml
.XmlWebApplicationContext
当然可以访问您的Web应用程序中包含的文件,但这不是最重要的事情.它实现了 WebApplicationContext ,这意味着它将检测到 ServletContextAware bean ,注册自定义范围(请求,会话等).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.这篇关于类路径,文件系统之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!