类路径,文件系统之间有什么区别? [英] What is difference between class path , file system?

查看:140
本文介绍了类路径,文件系统之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道:

  1. 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 in classes folder of your web application or in a jar in your libfolder.

      FileSystemXmlApplicationContext可以访问您的所有文件系统,例如c:/config/applicationContext.xml.

      FileSystemXmlApplicationContext can access all your file system, for example c:/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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆