2013-02-09 95 views
0

我无法运行该程序。Spring DI演示中的ClassNotFoundException问题

线程“main”中的异常org.springframework.beans.factory.CannotLoadBeanClassException:在类路径resource [beans.xml]中定义的名称为'hello'的bean找不到类[com.tutorialspoint.HelloWorld];嵌套的例外是抛出java.lang.ClassNotFoundException:

enter image description here

enter image description here

enter image description here

回答

3

你的bean定义必须指向类不包名

<bean id="hello" class="com.tutorialspoint.HelloWorld.MainApp"> 
    <property name="message" value="Hello Man"></property> 
</bean> 
+0

我是初学者在泉城,我发现这个答案有帮助 – Kay 2015-06-07 21:41:18

0

您的Spring Bean配置是完美的,但你必须为ApplicationCont提供正确的路径根据你的代码在MainApp类中的ext,你的路径应该是“main/resource/beans.xml”。希望这会工作...