JavaSpring:创建bean时出错
我在Eclipse中添加了一个spring项目。从eclipse在服务器上运行project时,会出现以下错误:JavaSpring:创建bean时出错,java,eclipse,spring,hibernate,spring-mvc,Java,Eclipse,Spring,Hibernate,Spring Mvc,我在Eclipse中添加了一个spring项目。从eclipse在服务器上运行project时,会出现以下错误: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/myprojectwebsite-servlet.xml]: Invocation of init method failed; nested exception is org.hibernate.Ma
Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/myprojectwebsite-servlet.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to load class declared as <mapping class="com.test.myproject.data.User"/> in the configuration:
Caused by: org.hibernate.MappingException: Unable to load class declared as <mapping class="com.test.myproject.data.User"/> in the configuration:
创建在ServletContext资源[/WEB-INF/myprojectwebsite servlet.xml]中定义了名为“sessionFactory”的bean时出错:调用init方法失败;嵌套异常为org.hibernate.MappingException:无法加载配置中声明的类:
原因:org.hibernate.MappingException:无法加载在配置中声明为的类:
myprojectwebsite-servlet.xml具有:
...
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
...
。。。
类路径:hibernate.cfg.xml
...
hibernate.cfg.xml中有引发错误的代码:
<mapping class="com.test.myproject.data.User"/>
知道可能出了什么问题吗?运行时是否可以访问
用户
类?有没有办法检查?(我粘贴的错误来自eclipse控制台)在eclipse放置编译器输出的目录中,该类存在吗?单击ctrl+shift+t
并键入User
查看它显示了什么?您的代码是在GitHub上还是什么?