ClassPathXmlApplicationContext()与FileSystemXmlApplicationContext() 区别

// ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:appcontext.xml");

// ApplicationContext factory=new ClassPathXmlApplicationContext("appcontext.xml");

// ApplicationContext factory=new ClassPathXmlApplicationContext("file:G://workspace/workspace/example6/src/appcontext.xml");

     

       

//用文件系统的路径

//  ApplicationContext factory=new FileSystemXmlApplicationContext("src/appcontext.xml");    


//使用了  classpath:  前缀,作为标志,  这样,FileSystemXmlApplicationContext 也能够读入classpath下的相对路径

//  ApplicationContext factory=new FileSystemXmlApplicationContext("classpath:appcontext.xml");

 // ApplicationContext factory=new FileSystemXmlApplicationContext("file:G:/workspace/workspace/example6/src/appcontext.xml");

// ApplicationContext factory=new FileSystemXmlApplicationContext("G:/workspace/workspace/example6/src/appcontext.xml");

 

通过对比,牢记不同的使用方式。

你可能感兴趣的:(File)