ApplicationContext context = new ClassPathXmlApplicationContext("D:/workspace/HelloJava/src/Bean.xml");
Bean bean = (Bean)context.getBean("beanid");Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [D:/workspace/HelloJava/src/Bean.xml]; nested exception is java.io.FileNotFoundException: class path resource [D:/workspace/HelloJava/src/Bean.xml] cannot be opened because it does not exist
webRoot\WEB-INF\classes\...
webRoot\WEB-INF\也能作为目录????
然后 在你的类文件里
写这句
ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
默认是找src目录下的
ApplicationContext context = new ClassPathXmlApplicationContext("Bean.xml");
Bean bean = (Bean)context.getBean("beanid");
那个类只能够用相对于类路径才能够找到
要全全路径需要使用文件系统路径类
你现在那个类只需要写src下面的包加类就行了