我从我的Spring web应用程序中得到一个500错误。提到的文件已正确命名,并且位于正确的包中。以下是错误消息。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping': Invocation of init method failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.dao.CommentDAO] for bean with name 'commentDAO' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.dao.CommentDAO
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.dao.CommentDAO] for bean with name 'commentDAO' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.dao.CommentDAO
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.controller.PagesController] for bean with name 'pagesController' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.controller.PagesController
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.controller.CommentController] for bean with name 'commentController' defined in ServletContext resource [/WEB-INF/ghs1986-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.controller.CommentController下面是ghs1986-servlet.xml的相关部分。
<bean id="commentDAO" class="com.dao.CommentDAO">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="pagesController" class="com.controller.PagesController" />
<bean id="commentController" class="com.controller.CommentController">
<property name="commentDAO" ref="commentDAO" />
</bean>发布于 2021-07-19 07:54:40
问题解决了。我需要CommentDAO上的@Component注解。
https://stackoverflow.com/questions/68433675
复制相似问题