spring4 hibernate5 struts2 整合时出现异常该怎么解决,求各位大神帮帮忙 1C

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path resource
[applicationContext.xml]: Instantiation of bean failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.orm.hibernate5.LocalSessionFactoryBean]:
No default constructor found; nested exception is
java.lang.UnsupportedClassVersionError: org/hibernate/cfg/Configuration
: Unsupported major.minor version 52.0 (unable to load class
org.hibernate.cfg.Configuration)

5个回答

你的SQL驱动用的mysql的,你看下你的db配置是不是有问题。我之前遇到的问题就是因为用的SQL配置与驱动JAR包不一直导致的

u013749444
近了 没有吧,之前都是用这个数据库配置,可以连接上,配置都是在spring配置文件中的,就是上面的图片,你看看有什么问题吗?
3 年多之前 回复

别人说是jdk版本不对,我都换过了,还是没有用,是不是jar包的问题呢?

图片说明

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
    <property name="jdbcUrl" value="jdbc:mysql:///ssh_crm"></property>
    <property name="user" value="root"></property>
    <property name="password" value="root"></property>
 </bean>

 <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
 </bean>

 <!-- 事务管理 -->
 <bean id="transactionManager" 
    class="org.springframework.orm.hibernate5.HibernateTransactionManager"></bean>
 <tx:annotation-driven transaction-manager="transactionManager"/>


 <bean id="userAction" class="action.UserAction" scope="prototype">
    <property name="userService" ref="userService"></property>
 </bean>

 <bean id="userService" class="service.UserService">
    <property name="userDao" ref="userDaoImpl"></property>
 </bean>

 <bean id="userDaoImpl" class="dao.UserDaoImpl">
    <property name="hibernateTemplate" ref="hibernateTemplate"></property>
 </bean>

 <bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
    <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>

代码的编译版本不对,不是jdk版本

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐