You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring与Hibernate整合报错:无法创建RequestMappingHandlerMapping Bean

Spring & Hibernate Integration: Context Initialization Failed (BeanCreationException with LocalSessionFactoryBean)

Hi everyone, I'm currently learning Spring and Hibernate integration development using Java 17.0.4, Hibernate 5.3.26, and Spring 5.0.2. I'm following Chad Darby's Udemy course Spring and Hibernate for Beginners (includes Spring Boot).

When starting my project, I ran into a context initialization failure. Here's the full stack trace:

Aug 29, 2022 2:47:41 PM org.springframework.web.servlet.FrameworkServlet initServletBean
SEVERE: Context initialization failed
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.BeanCreationException: Error creating bean with name 'sessionFactory': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.orm.hibernate5.LocalSessionFactoryBean] from ClassLoader [ParallelWebappClassLoader context: web-customer-tracker delegate: false ----------> Parent Classloader: java.net.URLClassLoader@458ad742

Below are the relevant files from my project:

CustomerController.java

package com.luv2code.springdemo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/customer")
public class CustomerController {
    @RequestMapping("/list")
    public String listCustomers(Model theModel) {
        return "list-customers";
    }
}

list-customers.jsp

<!DOCTYPE html>
<html>
<head>
    <title>List Customers</title>
</head>
<body>
List Customers - coming soon ...
</body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
    <display-name>spring-mvc-crud-demo</display-name>
    <absolute-ordering />
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring-mvc-crud-demo-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

The error seems to center around the sessionFactory bean and a failure to introspect LocalSessionFactoryBean. I'd really appreciate any help figuring out the root cause and how to fix this issue.


内容的提问来源于stack exchange,提问作者BuzzSkywalkerV

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.27 18:43:11