Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

spring - What is difference between class path , file system?

I know that:

  1. ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");

    loads context definition from an XML file located in the classpath, treating context definitions as classpath resources.

  2. ApplicationContext context = new FileSystemXmlApplicationContext("bean.xml");

    loads context definition from an XML file in the filesystem.

  3. XmlWebApplicationContext

    loads context definition from an XML file contained within a web application.

But, what does it exactly mean??

Thanks :)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  • 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 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...