你Resource res = new ClassPathResource("javamxj/spring/beginning3/HelloBean.xml");这个地方错了,这里应该是你spring的配置文件的路径,spring默认的是ApplicationContext.xml文件,你的是HelloBean.xml??,你把Spring的配置文件路径指正确了就可以了。
如果你测试程序的话,你把ApplicationContext.xml文件拷贝到src目录下,这样写就可以了。
public static void main(String[] args) {
HelloBean helloBean = new HelloBean();
System.out.println(helloBean.getHelloWorld()); // 利用Spring调用HelloBean
Resource res = new ClassPathResource("applicationContext.xml"); BeanFactory factory = new XmlBeanFactory(res);
helloBean = (HelloBean) factory.getBean("HelloBean");
System.out.println(helloBean.getHelloWorld());
}

解决方案 »

  1.   

    将你的XML文件放在 WEB-INF/classes(src)文件夹下面,
    并把Resource res = new ClassPathResource("javamxj/spring/beginning3/HelloBean.xml");
    改为Resource res = new ClassPathResource("HelloBean.xml");
    就可以了因为ClassPathResource是在你classes目录下去查找XML文件的
      

  2.   

    你的HelloBean里有setHelloWorld()方法吗?
      

  3.   

    你HelloBean.xm放在哪个路径下了?
    正确的应该是classes/javamxj/spring/beginning3目录下
      

  4.   

    你可以看看这个贴子。。
    http://community.csdn.net/Expert/topic/5099/5099650.xml?temp=.2599451
      

  5.   

    应该是HelloBean.xml 放错位置了.