Unable to start java application using spring orm

218 views Asked by At

Problem Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [config.xml]: Failed to instantiate [org.springframework.orm.hibernate5.HibernateTemplate]: No default constructor found

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

    xsi:schemaLocation="http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://www.springframework.org/schema/aop 
  http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  http://www.springframework.org/schema/context 
  http://www.springframework.org/schema/context/spring-context-2.5.xsd
  http://www.springframework.org/schema/tx 
  http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
    >
    
    <tx:annotation-driven/>
    
    <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" name="ds">
    
        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/springorm"/>
        <property name="username" value="root"/>
        <property name="password" value="ParaSF@59"/>
        
    </bean>
    
    <bean class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" name="factory">
            
            <property name="dataSource" ref="ds" ></property>
            
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.MySQL8Dialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                </props>
            </property>
            
            <property name="annotatedClasses">
                <list>
                    <value>
                        com.spring.orm.entity.Student
                    </value>
                </list>
            </property>
                
    </bean>

    <bean class=" org.springframework.orm.hibernate5.HibernateTemplate" name="hibernateTemplate">   
        <property name="sessionFactory" ref="factory"></property>
    </bean>
    
    <bean class="com.spring.orm.dao.StudentDao" name="studentDao">  
            <property name="hibernateTemplate" ref="hibernateTemplate"></property>
    </bean>
    
    <bean class="org.springframework.orm.hibernate5.HibernateTransactionManager" name="transactionManager">
        <property name="sessionFactory" ref="factory"/>
    </bean>
 
</beans>
0

There are 0 answers